Documentation
¶
Overview ¶
Package nats provides essessey.Sink and essessey.Source bindings for NATS.
NATS is message-oriented: every publish is already a discrete message, so this package needs no SSE-style framing — that framing exists only because an HTTP body is an undelimited byte stream. Sink publishes essessey.Event.Data raw; Source hands events back exactly as they were delivered.
This package deliberately does NOT import github.com/nats-io/nats.go. Publisher declares the one method (Publish(subject string, data []byte) error) this package actually needs, and *nats.Conn already satisfies it structurally — the caller passes their own client, and essessey adds zero transport dependency. This is a design choice, not a missing feature: pulling in the real client would tie essessey's module graph to one NATS driver version for the sake of a single method.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Publisher ¶
Publisher is the minimal capability this package needs from a NATS client: publish raw bytes to a subject.
*nats.Conn (github.com/nats-io/nats.go) satisfies this method as-is. Callers pass their own connection — see the package doc comment for why this package never imports the nats client library itself.
type Sink ¶
type Sink struct {
// contains filtered or unexported fields
}
Sink publishes essessey events to NATS subjects.
NATS already delimits messages, so Emit publishes ev.Data RAW — no SSE-style framing. The subject is the configured prefix plus the event's type, so a subscriber can filter with a NATS wildcard subject (subjectPrefix.*) without inspecting payloads.
A real *nats.Conn is safe for concurrent Publish calls, so Emit needs no mutex of its own — it holds no other mutable state.
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
Source turns a NATS subscription's push-callback delivery into an essessey.Source. Wire Deliver as the subscription callback; Next pulls events off in the order they arrived.
func (*Source) Close ¶
func (s *Source) Close()
Close stops the source. Next drains any already-buffered events first, then returns essessey.ErrNoMoreEvents. Close is idempotent.