Comments (4)
If we go for this approach, we also need to solve how to talk to PID's from outside an actor.
this could be done by having a Tell
func directly in actor
actor.Tell(pid, msg)
That would be a "contextless" Tell.
If you have some sort of context, for example Zipkin data, and you want to call into the actor world using this context.
We could have something like this:
ctx := actor.NewRootContext( whatever context data)
defer ctx.Close()
ctx.Tell(pid, msg)
I think this would be fairly clean, even if this approach is more verbose than what we have currently.
from protoactor-go.
I'm not too familiar with how the context and PID interact yet, but from a user perspective I think it's important that there are as few ways as possible of doing something, preferably just one if possible.
Would it be a bad coupling if the PID knew about the context it belongs to? So calling pid.Tell
would notify the context of the Tell operation, so it can do tracing or whatever it is it needs to do.
from protoactor-go.
making the PID know about the current context is possible in e.g C# using AsyncLocal and all that black magic.
It is less doable in Go as Go has its own concept of Go routines, there are hacks to peek into thread local like storage for this, but I don't want to go there.
(The same PID could flow through multiple contexts in e.g. a message, so it is not tied to the context in any way)
Another option could be to provide the context into the pid.Tell(msg, context)
that would be less intrusive on the current design, right?
the last context param might be an arglist of context providers. passing nothing would mean telling from the root context.
Just tossing around ideas here
from protoactor-go.
Discussed API:
context.Tell(pid, message)
We could either go for:
context.Tell(pid, message)
context.TellRaw(pid, bytes)
(or somilar)
or
context.Tell(pid, Message{Object: msg})
context.Tell(pid, Message{Bytes: bytes})
Related tasks
- Introducing a message envelope type carrying message headers, this type can also replace the current
messageSender
type
e.g.
type struct Message {
Headers MessageHeaders // string -> string map
Object interface{}
Bytes []byte
Sender *PID //this could be tricky as PID lives in actor package
}
- Make all queues carry this message envelope instead of interface{}
- Introduce way of reading message headers from actor Context
- Introduce outbound middleware allowing code to read from actor context and write to outgoing message headers
- Introduce a
RootContext
which can be used when integrating with actors from the outside world
e.g.
func main() {
pid := ...
...
ctx := NewRootContext()
ctx.Headers().Add("TraceID", "123") //the rootcontext can be configured with some initial values
//or possibly, root context headers should be set on creation?
ctx.Tell(pid, message)
}
One question we need to decide on,
Do we keep Tell on the PID for convenience? e.g. when interacting with actors from the outside.
or do we provide a default empty root context through actor.Tell
or something similar?
from protoactor-go.
Related Issues (20)
- ensureTopicKindRegistered is not a good idea HOT 1
- subscriber may block PubSubMemberDeliveryActor
- Remove sprintf logging HOT 1
- Batch message sent twice? HOT 2
- Logging is a breaking change HOT 1
- MemberStrategy is not work!!!
- Go coroutine thread safe HOT 2
- Is every actor message Receiver run in they own goroutine ? HOT 1
- How can a member within a cluster be restarted? HOT 2
- How can I make ‘Spawn’ return the error that occurred when 'Started' is received? HOT 4
- Data Race
- Possible memory leak HOT 4
- Error when sending large message to remote actors HOT 1
- Context propagation HOT 1
- The release tag "0.4.0" does not work
- About using your code, and copyright
- protoc-gen-gograinv2 cannot recognize google.protobuf.Empty
- How to do grain reentrance HOT 2
- Improve code generation HOT 1
- Remove GrainResponse HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protoactor-go.