Documentation
¶
Index ¶
Examples ¶
Constants ¶
const ComponentId = 6462
Identfier of the package found messages having the format "senzing-6462xxxx".
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MessageFormat ¶ added in v0.2.0
type ObserverGrpc ¶ added in v0.2.2
type ObserverGrpc struct { GrpcClient observerpb.ObserverClient Id string }
ObserverGrpc sends the observed message to a Grpc server.
func (*ObserverGrpc) GetObserverId ¶ added in v0.2.2
func (observer *ObserverGrpc) GetObserverId(ctx context.Context) string
The GetObserverId method returns the unique identifier of the observer. Use by the subject to manage the list of Observers.
Input
- ctx: A context to control lifecycle.
func (*ObserverGrpc) UpdateObserver ¶ added in v0.2.2
func (observer *ObserverGrpc) UpdateObserver(ctx context.Context, message string)
The UpdateObserver method processes the message sent by the Subject. The subject invokes UpdateObserver as a goroutine.
Input
- ctx: A context to control lifecycle.
- message: The string to propagate to all registered Observers.
type ObserverNull ¶
ObserverNull is a simple example of the Subject interface. It is mainly used for testing.
func (*ObserverNull) GetObserverId ¶
func (observer *ObserverNull) GetObserverId(ctx context.Context) string
The GetObserverId method returns the unique identifier of the observer. Use by the subject to manage the list of Observers.
Input
- ctx: A context to control lifecycle.
Example ¶
// For more information, visit https://github.com/Senzing/go-observing/blob/main/observer/observer_test.go ctx := context.TODO() observer := &ObserverNull{ Id: "1", } fmt.Print(observer.GetObserverId(ctx))
Output: 1
func (*ObserverNull) UpdateObserver ¶
func (observer *ObserverNull) UpdateObserver(ctx context.Context, message string)
The UpdateObserver method processes the message sent by the Subject. The subject invokes UpdateObserver as a goroutine.
Input
- ctx: A context to control lifecycle.
- message: The string to propagate to all registered Observers.
Example ¶
// For more information, visit https://github.com/Senzing/go-observing/blob/main/observer/observer_test.go ctx := context.TODO() observer := &ObserverNull{ Id: "1", } observer.UpdateObserver(ctx, "A message")
Output: Observer: 1; Message: A message
type ObserverRaw ¶ added in v0.2.5
ObserverNull is a simple example of the Subject interface. It is mainly used for testing.
func (*ObserverRaw) GetObserverId ¶ added in v0.2.5
func (observer *ObserverRaw) GetObserverId(ctx context.Context) string
The GetObserverId method returns the unique identifier of the observer. Use by the subject to manage the list of Observers.
Input
- ctx: A context to control lifecycle.
func (*ObserverRaw) UpdateObserver ¶ added in v0.2.5
func (observer *ObserverRaw) UpdateObserver(ctx context.Context, message string)
The UpdateObserver method processes the message sent by the Subject. The subject invokes UpdateObserver as a goroutine.
Input
- ctx: A context to control lifecycle.
- message: The string to propagate to all registered Observers.
type ObserverWhiteList ¶ added in v0.2.0
ObserverNull is a simple example of the Subject interface. It is mainly used for testing.
func (*ObserverWhiteList) GetObserverId ¶ added in v0.2.0
func (observer *ObserverWhiteList) GetObserverId(ctx context.Context) string
The GetObserverId method returns the unique identifier of the observer. Use by the subject to manage the list of Observers.
Input
- ctx: A context to control lifecycle.
Example ¶
ctx := context.TODO() observer := &ObserverWhiteList{ Id: "1", } fmt.Print(observer.GetObserverId(ctx))
Output: 1
func (*ObserverWhiteList) UpdateObserver ¶ added in v0.2.0
func (observer *ObserverWhiteList) UpdateObserver(ctx context.Context, message string)
The UpdateObserver method processes the message sent by the Subject. The subject invokes UpdateObserver as a goroutine.
Input
- ctx: A context to control lifecycle.
- message: The string to propagate to all registered Observers.
Example ¶
ctx := context.TODO() message11 := `{"subjectId":"1", "messageId": "1"}` message12 := `{"subjectId":"1", "messageId": "2"}` message21 := `{"subjectId":"2", "messageId": "1"}` message22 := `{"subjectId":"2", "messageId": "2"}` message31 := `{"subjectId":"3", "messageId": "1"}` observer := &ObserverWhiteList{ Id: "1", WhiteList: map[int]map[int]bool{ 1: { 1: true, 2: true, }, 2: { 2: true, }, }, } observer.UpdateObserver(ctx, message11) observer.UpdateObserver(ctx, message12) observer.UpdateObserver(ctx, message21) observer.UpdateObserver(ctx, message22) observer.UpdateObserver(ctx, message31)
Output: Observer: 1; Message: {"subjectId":"1", "messageId": "1"} Observer: 1; Message: {"subjectId":"1", "messageId": "2"} Observer: 1; Message: {"subjectId":"2", "messageId": "2"}