-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rewrite events handling to remove watermill
As discussed in the community call, watermill doesn't give us the necessary features we'd like to utilize with the underlying nats message. We decided to switch to using nats directly but still wanted some support for possibly changing this out later. This rewrites events to use our own interfaces to allow for the possibility of a different event driver later. Additionally this switches to using pull subscriptions instead of push, supports Ack, Nak and Term as well as Request/Reply semantics. Due to the Request/Reply semantics, no longer are there separate Publisher and Subscriber configurations as the driver needs to be able to handle both. Signed-off-by: Mike Mason <[email protected]>
- Loading branch information
Showing
16 changed files
with
1,221 additions
and
672 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package events | ||
|
||
import "context" | ||
|
||
// Connection defines a connection handler. | ||
type Connection interface { | ||
// Gracefully close the connection. | ||
Close(ctx context.Context) error | ||
|
||
// Source gives you the raw underlying connection object. | ||
Source() any | ||
} | ||
|
||
// Subscriber specifies subscriber methods. | ||
type Subscriber interface { | ||
Connection | ||
|
||
// Subscribe subscribes to the provided topic responding a message. | ||
Subscribe(ctx context.Context, topic string) (<-chan Message[any], error) | ||
// SubscribeAuthRelationshipRequests subscribes to the provided topic responding with an AuthRelationshipRequest message. | ||
SubscribeAuthRelationshipRequests(ctx context.Context, topic string) (<-chan Message[AuthRelationshipRequest], error) | ||
// SubscribeChanges subscribes to the provided topic responding with an ChangeMessage message. | ||
SubscribeChanges(ctx context.Context, topic string) (<-chan Message[ChangeMessage], error) | ||
// SubscribeEvents subscribes to the provided topic responding with an EventMessage message. | ||
SubscribeEvents(ctx context.Context, topic string) (<-chan Message[EventMessage], error) | ||
} | ||
|
||
// Publisher specifies publisher methods. | ||
type Publisher interface { | ||
Connection | ||
|
||
// Publish publishes to the specified topic with the message given. | ||
Publish(ctx context.Context, topic string, message any) (Message[any], error) | ||
// PublishAuthRelationshipRequest publishes to the specified topic with the message given. | ||
PublishAuthRelationshipRequest(ctx context.Context, topic string, message AuthRelationshipRequest) (Message[AuthRelationshipResponse], error) | ||
// PublishChange publishes to the specified topic with the message given. | ||
PublishChange(ctx context.Context, topic string, message ChangeMessage) (Message[ChangeMessage], error) | ||
// PublishEvent publishes to the specified topic with the message given. | ||
PublishEvent(ctx context.Context, topic string, message EventMessage) (Message[EventMessage], error) | ||
} | ||
|
||
// PubSub includes both publisher and subscriber methods. | ||
type PubSub interface { | ||
Connection | ||
Subscriber | ||
Publisher | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.