Files
wehub-resource-sync 1b8708893a
Security Scan / tests (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:12:26 +08:00

28 lines
984 B
Go

package messaging
import "time"
// Publisher publishes JSON-encoded messages to NATS subjects.
type Publisher interface {
Publish(subject string, data any) error
}
// Subscription represents a NATS subscription that can be unsubscribed.
type Subscription interface {
Unsubscribe() error
}
// MessagingClient is the full interface for NATS messaging operations.
// Consumers should depend on this interface rather than the concrete Client
// for testability.
type MessagingClient interface {
Publisher
Subscribe(subject string, handler func([]byte)) (Subscription, error)
QueueSubscribe(subject, queue string, handler func([]byte)) (Subscription, error)
QueueSubscribeReply(subject, queue string, handler func(data []byte, reply func([]byte))) (Subscription, error)
SubscribeReply(subject string, handler func(data []byte, reply func([]byte))) (Subscription, error)
Request(subject string, data []byte, timeout time.Duration) ([]byte, error)
IsConnected() bool
Close()
}