Hi Doug,
The ThreadLocal approach would be an easy way to communicate per-call
metadata between the application and the Requstor/Responder without
having to add explicit API. I just started picking up the Avro code,
and so I have a question: is it possible for a Requestor or Responder
to be used by more than one thread? On the flip side, is it possible
for a thread to have more than one Requestor?
If (as I expect) it is possible for a thread to have multiple
Requestors open (but Requestors could not be shared to more than one
thread), then the ThreadLocal could be a Map<Requestor, metadata>.
This way you could set per-call metadata on a per-requestor basis even
if multiple requestors are open. We could provide some static methods
as you mentioned to facilitate this.
So that I understand, in this case the call format for the request
would then become:
- the message name, an avro string, followed by the message
parameters
- the per-call metadata, which is a map. By default the map is null
and the call response would become
- a one byte error flag boolean (with either a message response or
error)
- the per-call metadata, which is a map. By default the map is null
Before you had mentioned that the metadata could be sent in
Transceiver.transceive. But couldn't it also be sent in
Requestor.request() (approximately at the writeRequset() call)?
What do people think of proceeding with Doug's recommendation of using
ThreadLocals, and including the map in the call request and response?
Thanks,
George
On Jun 29, 2009, at 4:09 PM, Doug Cutting wrote:
George Porter wrote:
If we would have to create an API for (optional) per-call metadata,
then I think we should go ahead and make it part of the spec from
the get-go. We can then implement both the API and the spec change.
Can we do it by Wednesday? I was hoping to freeze the 1.0 spec on
Wednesday. We could easily add it to the spec and read/write empty
metadata maps in the impls. Providing a nice API might be a little
harder. I guess it could be easily hacked through threadlocals:
Requestor and Responder could just copy things from/to threadlocal
maps, accessed via static methods. Would that suffice?
Doug