-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmessage.go
62 lines (50 loc) · 2.01 KB
/
message.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package dogma
// A Message is an application-defined unit of data that describes a [Command],
// [Event], or [Timeout] within a message-based application.
type Message interface {
// MessageDescription returns a human-readable description of the message.
MessageDescription() string
}
// A Command is a message that represents a request for a Dogma application to
// perform some action.
type Command interface {
// MessageDescription returns a human-readable description of the message.
MessageDescription() string
// Validate returns a non-nil error if the message is invalid.
Validate(CommandValidationScope) error
}
// An Event is a message that indicates that some action has occurred within a
// Dogma application.
type Event interface {
// MessageDescription returns a human-readable description of the message.
MessageDescription() string
// Validate returns a non-nil error if the message is invalid.
Validate(EventValidationScope) error
}
// A Timeout is a message that represents a request for an action to be
// performed at a specific time.
type Timeout interface {
// MessageDescription returns a human-readable description of the message.
MessageDescription() string
// Validate returns a non-nil error if the message is invalid.
Validate(TimeoutValidationScope) error
}
// UnexpectedMessage is a panic value used by a message handler when it receives
// a message of a type that it did not expect.
var UnexpectedMessage unexpectedMessage
type unexpectedMessage struct{}
// CommandValidationScope provides information about the context in which a
// [Command] is being validated.
type CommandValidationScope interface {
reservedCommandValidationScope()
}
// EventValidationScope provides information about the context in which an
// [Event] is being validated.
type EventValidationScope interface {
reservedEventValidationScope()
}
// TimeoutValidationScope provides information about the context in which a
// [Timeout] is being validated.
type TimeoutValidationScope interface {
reservedTimeoutValidationScope()
}