-
-
Notifications
You must be signed in to change notification settings - Fork 276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add operationId for the reply #981
Comments
This is, to me, the important issue here. Wondering if then would make sense to suggest we reference an operation in the operations:
pingRequest:
action: send
channel:
$ref: '#/channels/ping'
reply:
$ref: '#/operations/pingReply'
pingReply:
action: receive
channel:
$ref: '#/channels/pong' I'm not sure this has been considered in the original issue 🤔 |
The
operations:
pingRequest:
action: send
channel:
$ref: '#/channels/ping'
reply:
channel:
$ref: '#/channels/pong'
operations:
pongReply:
action: receive
channel:
$ref: '#/channels/ping'
reply:
channel:
$ref: '#/channels/pong' The reply:
channel:
$ref: '#/channels/pong' and could be reused by the reference. |
operation reply is not the same as operation, we should not enable referencing there. Also adding operation for just reply should not happen, as reply is not a default operation of the app, it is just an operation that happens as a result of the core operation it is located it. for me it sounds like reply simply needs it's own unique operationId 🤔 |
could we allow design like: operations:
pingRequest:
action: send
channel:
$ref: '#/channels/ping'
reply:
pongReply:
channel:
$ref: '#/channels/pong' ? Consequently operations:
pingRequest:
action: send
channel:
$ref: '#/channels/ping'
reply:
$ref: '#/reply/pongReply'
components:
reply:
pongReply:
channel:
$ref: '#/channels/pong' |
That's a remarcable caveat indeed @Tenischev. With the current dereference behaviour, we can't overwrite properties of the referenced object like in the following example: # requestor.yaml
operations:
pingRequest:
$ref: './common.yaml#/operations/pingRequest'
pongReply:
$ref: './common.yaml#/operations/pongRequest' # replier.yaml
operations:
pingRequest:
$ref: './common.yaml#/operations/pingRequest'
action: receive
pongReply:
$ref: './common.yaml#/operations/pongRequest'
action: send # common.yaml
# ...
operations:
pingRequest:
action: send
channel:
$ref: '#/channels/ping'
reply:
$ref: '#/operations/pongReply'
pongReply:
action: receive
channel:
$ref: '#/channels/pong' Unfortunately, this is not probably gonna happen in the near future. So nothing is viable on that side atm unless we finally give priority to that. Also, I didn't think about recursivity in the case of allowing referencing an Operation here that has a circular ref on the reply... So it's definitely not trivial. Anyway, in that same path, adding
Even though you can read my answer to @Tenischev above, I still don't really see such a difference. A reply to a request it's an operation that is triggered by another operation. I see it in that way. |
@derberg @smoya |
@Tenischev I dont agree with your argumentation that you need a dedicated reply method for responses. Please checkout this interface/lib: |
@GreenRover You are right, that reply not mandatory to be handled asynchronously and some libraries provide default methods to handle it synchronously.
|
Yes i know and understand that. As soon as you have to operations it is not a classic request reply pattern. Than you end up with something like this: operations:
sendPing:
action: send
channel:
$ref: '#/channels/ping'
receivePong:
action: receive
channel:
$ref: '#/channels/pong' This is also a very common design pattern. But here you don`t have a machine readable correlation between ping and pong. What is the target of your change? What is the requirement you currently can not solve? |
That's actually a good point @GreenRover. |
In order to not pollute this issue about the topic "Should reply object become an operation object?", I created #1009 |
Looks like we have a "something" (or a "classic") what was implicitly put into the specification. Which is at least for me - a problem. Who is define what is the "classic" and what's not?
I want to give to an user as much flexibility in the template as I can. Solution mentioned by you to use an async types like the Fututre form Java could be the good solution for the "send and reply", whereas for the "receive and reply" it's a bit more tricky. |
Can you provide examples that currently can not be solved. May this would helps me to understand your point a little better. |
@GreenRover it's described in first message, but let me give a more detailed example and sorry for java oriented pseudo-code. operations:
pingRequest:
action: send
channel:
$ref: '#/channels/ping'
reply:
channel:
$ref: '#/channels/pong' Approach 1. Use asynchronous object like Future (or another protocol specific) to handle reply public FutureMessage pingRequest(PingMessage ping) {
return broker.sendAndGetReply(ping, pongChannel);
} Simple code, but require from underling Approach 2. Use callback object to handle reply public void pingRequest(PingMessage ping) {
broker.sendAndReceive(ping, pingCallback);
}
CallbackOperation pingCallback = new Callback() {
public void onSuccess(ReplyMessage message) {
}
public void onError(Error e) {
}
} Callback implementation could be unified for some operations and write once. Here I used a class MessageSender {
public void pingRequest(PingMessage ping) {
broker.send(ping);
}
}
class MessageHandler {
public Message pingReply() {
return broker.receiveFromTopic(pong);
}
} This solution may be sufficient when user need to make a complicated logic on a reply which are not directly connected with sending itself. In addition we could scale instances of Of course these 3 implementation are not exhaustive and depending on broker, architecture approach e.t.c. user may want something else, but I could name them "common" that you'll find in most guides\books. |
I guess i understood what you wanted to say. But still can not aggress.
Recap: There is never an 2.) Your approach 3 is not working this easy. 3.) You pointed out a general problem of AsyncApi: Is the documentation in perspective of client or server. Is not only given for RequestReply. The same problem exists for operation.action: But in #1009 your brough up a good point |
I think it's clear. I do not plan to reinvent application-broker communication protocol, I have libraries for this.
Yes, they are a library functions, but I didn’t say otherwise.
The Spec, the AsyncAPI file should show how messages are goes between applications.
|
This issue has been automatically marked as stale because it has not had recent activity 😴 It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation. There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model. Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here. Thank you for your patience ❤️ |
During check of what changes should be done in template to support Spec v3, I struggling with
reply
definition.At least in Java world it's preferable to have a separate method definition for
send
andreceive
Message.So, for example we have following:
From this definition of API I could generate method to
send
message and name itpingRequest
based on the name of operation.But I also should create a method to receive the
reply
and here I have a problem, because thereply
has no name and Operation Reply Object has no field where user could provide the name.As hardcoded solution, I could generate method with name like
pingRequestReply
( + "Reply"), but this approach has a drawback, since occasionally name generated in this way may overlap with name of another operation defined by user in an API.Thus, I would prefer to have something like
operationId
in fields of Operation Reply Object where user could define a desired name for generated method.The text was updated successfully, but these errors were encountered: