permaweb / aos

An operating system for AO: The hyper parallel computer
https://ao.g8way.io
Other
68 stars 46 forks source link

Standardize response messages in token.lua #291

Open dvinubius opened 2 months ago

dvinubius commented 2 months ago

Solves https://github.com/permaweb/aos/issues/290

Any response message is tagged with ["Response-For"] = <Name-Of-The-Action> in order to be more easily matchable by the receiver of the response.

hitwill commented 2 months ago

https://github.com/permaweb/aos/issues/290#issuecomment-2224063356

kprimice commented 2 months ago

Can't you use the built-in Pushed-For for that purpose? (it is the Message-Id that any message was pushed for)

dvinubius commented 2 months ago

@kprimice Pushed-For propagates in a longer message chain. If the Request-Type message is sent as a consequence of handling another message, then the Response-Type message that follows will have a Pushed-For with the ID of the initial message.

The proposed solution is more focused on a single request-response message exchange, regardless of the broader message handling context

twilson63 commented 1 month ago

Any reason, not to use Reference and X-Reference

local response = Send({...}).receive()
-- process response?

or

Send({...}).onReply(function (msg)
  -- do stuff
 end)

This is currently in preview (Release Candidate) if you want to try