pubsub

package
v0.0.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package pubsub wraps nats calls

Index

Constants

View Source
const (
	// CreateEventType is the create event type string
	CreateEventType = "create"
	// DeleteEventType is the delete event type string
	DeleteEventType = "delete"
	// UpdateEventType is the update event type string
	UpdateEventType = "update"
)
View Source
const (
	// DefaultMessageSource is the default source for messages
	DefaultMessageSource = "load-balancer-api"
)

Variables

View Source
var (
	// ErrMissingEventSubjectURN is returned when the event subject urn is missing
	ErrMissingEventSubjectURN = errors.New("missing event subject urn")

	// ErrMissingEventActorURN is returned when the event actor urn is missing
	ErrMissingEventActorURN = errors.New("missing event actor urn")

	// ErrMissingEventSource is returned when the event source is missing
	ErrMissingEventSource = errors.New("missing event source")
)

Functions

func NewAssignmentURN

func NewAssignmentURN(id string) string

NewAssignmentURN creates a new assignment URN

func NewLoadBalancerURN

func NewLoadBalancerURN(id string) string

NewLoadBalancerURN creates a new load balancer URN

func NewMessage added in v0.0.14

func NewMessage(tenantURN string, opts ...MsgOption) (*pubsubx.Message, error)

NewMessage functionally generates a new pubsub message and appends the tenantURN to the list of additional subject urns

func NewMetadataURN added in v0.0.16

func NewMetadataURN(id string) string

NewMetadataURN creates a new metadata URN

func NewOriginURN added in v0.0.9

func NewOriginURN(id string) string

NewOriginURN creates a new origin URN

func NewPoolURN added in v0.0.9

func NewPoolURN(id string) string

NewPoolURN creates a new pool URN

func NewPortURN added in v0.0.10

func NewPortURN(id string) string

NewPortURN creates a new port URN

func NewTenantURN added in v0.0.9

func NewTenantURN(id string) string

NewTenantURN creates a new tenant URN

Types

type Client added in v0.0.8

type Client struct {
	// contains filtered or unexported fields
}

Client is an event bus client with some configuration

func NewClient added in v0.0.8

func NewClient(opts ...Option) *Client

NewClient configures and establishes a new event bus client connection

func (*Client) AddStream added in v0.0.8

func (c *Client) AddStream() (*nats.StreamInfo, error)

AddStream checks if a stream exists and attempts to create it if it doesn't. Currently we don't currently check that the stream is configured identically to the desired configuration.

func (*Client) ChanSubscribe added in v0.0.9

func (c *Client) ChanSubscribe(_ context.Context, sub string, ch chan *nats.Msg, stream string) (*nats.Subscription, error)

ChanSubscribe creates a subcription and returns messages on a channel

func (*Client) PublishCreate added in v0.0.8

func (c *Client) PublishCreate(ctx context.Context, actor, location string, data *pubsubx.Message) error

PublishCreate publishes a create event

func (*Client) PublishDelete added in v0.0.8

func (c *Client) PublishDelete(ctx context.Context, actor, location string, data *pubsubx.Message) error

PublishDelete publishes a delete event

func (*Client) PublishUpdate added in v0.0.8

func (c *Client) PublishUpdate(ctx context.Context, actor, location string, data *pubsubx.Message) error

PublishUpdate publishes an update event

type MsgOption added in v0.0.14

type MsgOption func(m *pubsubx.Message)

MsgOption is a functional argument for NewMessage

func WithActorURN added in v0.0.14

func WithActorURN(u string) MsgOption

WithActorURN sets the actor urn of the message

func WithAdditionalData added in v0.0.14

func WithAdditionalData(d map[string]interface{}) MsgOption

WithAdditionalData sets the additional data of the message

func WithAdditionalSubjectURNs added in v0.0.14

func WithAdditionalSubjectURNs(a ...string) MsgOption

WithAdditionalSubjectURNs sets the additional subject urns of the message

func WithEventType added in v0.0.14

func WithEventType(e string) MsgOption

WithEventType sets the event type of the message

func WithSource added in v0.0.14

func WithSource(s string) MsgOption

WithSource sets the source of the message

func WithSubjectFields added in v0.0.14

func WithSubjectFields(f map[string]string) MsgOption

WithSubjectFields sets the subject fields of the message

func WithSubjectURN added in v0.0.14

func WithSubjectURN(s string) MsgOption

WithSubjectURN sets the subject urn of the message

type Option added in v0.0.8

type Option func(c *Client)

Option is a functional configuration option for governor eventing

func WithJetreamContext added in v0.0.8

func WithJetreamContext(js nats.JetStreamContext) Option

WithJetreamContext sets the nats jetstream context

func WithLogger added in v0.0.8

func WithLogger(l *zap.SugaredLogger) Option

WithLogger sets the client logger

func WithStreamName added in v0.0.8

func WithStreamName(s string) Option

WithStreamName sets the nats stream name

func WithSubjectPrefix added in v0.0.8

func WithSubjectPrefix(p string) Option

WithSubjectPrefix sets the nats subject prefix

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL