forked from asynkron/protoactor-go
/
message_producer.go
38 lines (29 loc) · 1.25 KB
/
message_producer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package actor
import "time"
type MessageProducer interface {
// Tell sends a messages asynchronously to the PID
Tell(pid *PID, message interface{})
// Request sends a messages asynchronously to the PID. The actor may send a response back via respondTo, which is
// available to the receiving actor via Context.Sender
Request(pid *PID, message interface{}, respondTo *PID)
// RequestFuture sends a message to a given PID and returns a Future
RequestFuture(pid *PID, message interface{}, timeout time.Duration) *Future
}
type rootMessageProducer struct {
}
var (
EmptyContext MessageProducer = &rootMessageProducer{}
)
// Tell sends a messages asynchronously to the PID
func (*rootMessageProducer) Tell(pid *PID, message interface{}) {
pid.Tell(message)
}
// Request sends a messages asynchronously to the PID. The actor may send a response back via respondTo, which is
// available to the receiving actor via Context.Sender
func (*rootMessageProducer) Request(pid *PID, message interface{}, respondTo *PID) {
pid.Request(message, respondTo)
}
// RequestFuture sends a message to a given PID and returns a Future
func (*rootMessageProducer) RequestFuture(pid *PID, message interface{}, timeout time.Duration) *Future {
return pid.RequestFuture(message, timeout)
}