Documentation
¶
Index ¶
- Variables
- func ConnectWithSecurity(_ context.Context, natsURL string, security *models.SecurityConfig, ...) (*nats.Conn, error)
- func TLSConfig(sec *models.SecurityConfig) (*tls.Config, error)
- type EventPublisher
- func ConnectWithEventPublisher(ctx context.Context, natsURL, streamName string, opts ...nats.Option) (*EventPublisher, *nats.Conn, error)
- func CreateEventPublisher(ctx context.Context, nc *nats.Conn, streamName string, subjects []string) (*EventPublisher, error)
- func CreateEventPublisherWithDomain(ctx context.Context, nc *nats.Conn, domain, streamName string, ...) (*EventPublisher, error)
- func NewEventPublisher(js jetstream.JetStream, streamName string, subjects []string) *EventPublisher
- func (p *EventPublisher) PublishDeviceLifecycleEvent(ctx context.Context, data *models.DeviceLifecycleEventData) error
- func (p *EventPublisher) PublishGatewayFirstSeenEvent(ctx context.Context, gatewayID, sourceIP, partition, remoteAddr string, ...) error
- func (p *EventPublisher) PublishGatewayHealthEvent(ctx context.Context, gatewayID, previousState, currentState string, ...) error
- func (p *EventPublisher) PublishGatewayOfflineEvent(ctx context.Context, gatewayID, sourceIP, partition string, lastSeen time.Time) error
- func (p *EventPublisher) PublishGatewayRecoveryEvent(ctx context.Context, gatewayID, sourceIP, partition, remoteAddr string, ...) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDeviceLifecycleEventDataNil is returned when device lifecycle event data is nil. ErrDeviceLifecycleEventDataNil = errors.New("device lifecycle event data is nil") // ErrEventPayloadNil is returned when event payload is nil. ErrEventPayloadNil = errors.New("event payload is nil") )
var ( // ErrMTLSRequired is returned when mTLS security is required but not configured ErrMTLSRequired = errors.New("mtls security required") // ErrCAParsingFailed is returned when CA certificate cannot be parsed ErrCAParsingFailed = errors.New("failed to parse CA certificate") )
Functions ¶
Types ¶
type EventPublisher ¶
type EventPublisher struct {
// contains filtered or unexported fields
}
EventPublisher provides methods for publishing OCSF events to NATS JetStream.
func ConnectWithEventPublisher ¶
func ConnectWithEventPublisher( ctx context.Context, natsURL, streamName string, opts ...nats.Option) (*EventPublisher, *nats.Conn, error)
ConnectWithEventPublisher creates a NATS connection with JetStream and returns an EventPublisher.
func CreateEventPublisher ¶
func CreateEventPublisher( ctx context.Context, nc *nats.Conn, streamName string, subjects []string) (*EventPublisher, error)
CreateEventPublisher creates an EventPublisher for an existing NATS connection.
func CreateEventPublisherWithDomain ¶
func CreateEventPublisherWithDomain( ctx context.Context, nc *nats.Conn, domain, streamName string, subjects []string) (*EventPublisher, error)
CreateEventPublisherWithDomain creates an EventPublisher with optional NATS domain support.
func NewEventPublisher ¶
func NewEventPublisher(js jetstream.JetStream, streamName string, subjects []string) *EventPublisher
NewEventPublisher creates a new EventPublisher for the specified stream.
func (*EventPublisher) PublishDeviceLifecycleEvent ¶ added in v1.0.55
func (p *EventPublisher) PublishDeviceLifecycleEvent(ctx context.Context, data *models.DeviceLifecycleEventData) error
PublishDeviceLifecycleEvent publishes lifecycle changes (delete, restore, etc.) for a device.
func (*EventPublisher) PublishGatewayFirstSeenEvent ¶ added in v1.0.79
func (p *EventPublisher) PublishGatewayFirstSeenEvent( ctx context.Context, gatewayID, sourceIP, partition, remoteAddr string, timestamp time.Time) error
PublishGatewayFirstSeenEvent publishes an event when a gateway reports for the first time.
func (*EventPublisher) PublishGatewayHealthEvent ¶ added in v1.0.79
func (p *EventPublisher) PublishGatewayHealthEvent( ctx context.Context, gatewayID, previousState, currentState string, data *models.GatewayHealthEventData) error
PublishGatewayHealthEvent publishes a gateway health event to the events stream.
func (*EventPublisher) PublishGatewayOfflineEvent ¶ added in v1.0.79
func (p *EventPublisher) PublishGatewayOfflineEvent( ctx context.Context, gatewayID, sourceIP, partition string, lastSeen time.Time) error
PublishGatewayOfflineEvent publishes a gateway offline event.
func (*EventPublisher) PublishGatewayRecoveryEvent ¶ added in v1.0.79
func (p *EventPublisher) PublishGatewayRecoveryEvent( ctx context.Context, gatewayID, sourceIP, partition, remoteAddr string, lastSeen time.Time) error
PublishGatewayRecoveryEvent publishes a gateway recovery event.