Replies: 5 comments 2 replies
-
One suggestion that isn't listed here is adding the protocol metadata to the underlying message:
The advantage of that is that a Rust worker could ignore the payload (and thus might be able to be handled internally to |
Beta Was this translation helpful? Give feedback.
-
Message typesUse a type per message to name formats:
Each message has a string-tagged type and a BARE schema, which can be defined as a part of "a protocol" like this:
With message types there would be no need for union types and it makes it easier to combine multiple types from different protocols, but naming might be hard as all types need to be unique in a context of client/service interaction. If multiple services use the same type name, the client cannot use both of them at the same time. |
Beta Was this translation helpful? Give feedback.
-
Looking at the examples, to make them work with a stream protocol publisher to look the same as the other examples, it would make sense to implement the "pass through" protocol to send binary data and force all the messages to have a protocol.
Or like this:
But ALL the payloads have to contain the protocol.
This also addresses the issue of double-encoding of binary payloads by Rust code. |
Beta Was this translation helpful? Give feedback.
-
Formalizing protocol API: https://github.com/ockam-network/proposals/pull/81 |
Beta Was this translation helpful? Give feedback.
-
After implementing protocol matching for stream protocol, it appears to be fairly complex. |
Beta Was this translation helpful? Give feedback.
-
The problem
Sometimes workers need to communicate with multiple services with messages encoded in multiple protocols.
On the routing level payload is a binary data, which is encoded with BARE encoding.
BARE encoding (just as any other structured binary encoding) expects both sides to have a schema.
When a worker needs to talk to a single service communicating in different protocols, it can use union types to distinguish between types of messages. But when it needs to talk to independent services they cannot share a union type.
Proposal
To separate protocols and user code some sort of metadata can be used to match which code should handle which type of message.
Ideally the library would handle the matching, while user code should only implement the message handling.
The routing protocol data should not be affected by adding the metadata.
Ideas
Use an address per type:
For each service a worker talks to use a different return_route address.
This way an address on which it receives a response will mark the type of response it should handle.
This may be implemented with multiple workers for different protocols, which would share some state or communicate with a "coordinating worker" or with matching on onward_route address.
In this case address will act as a metadata
Add metadata to payload:
Make the message format look like this
The payload might be encoded as a binary with BARE scema:
Use protocol ID in the metadata
In this case each protocol would have to define an id it talks in.
The main challenge is that the protocol id mapping to an actual protocol should be shared between nodes
As an improvement to that, the protocol id may be a more descriptive string
Use session ID in the metadata
Unlike the protocol id, session id may be chosen dynamically by the initial sender, the protocol depends on the receiver of this message.
The sender would have to associate expected type with a session id and store this association somewhere. Also if responder wants to send more messages to the sender, it would have to have such association as well.
Use request ID in the metadata
Unlike the session id, request id is generated for each request from the sender, so the sender doesn't need to save it.
Responder would need to use a request_id received from the sender when sending responses
To allow responder to initiate new requests to the sender, this type can be extended to distinguish request id and response id
Responder will use request id from the requests as response id and may add request id allowing two-way request-response communication.
Combining request id with protocol/session id
Request-response identity may be useful for identifying a specific message and not only the protocol.
This might be an overkill for this particular problem
Beta Was this translation helpful? Give feedback.
All reactions