driver

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	Strategy    eventbusv1alpha1.AuthStrategy
	Crendential *AuthCredential
}

Auth contains the auth infor for event bus

type AuthCredential

type AuthCredential struct {
	Token    string
	Username string
	Password string
}

AuthCredential host the credential info

type Connection

type Connection interface {
	Close() error

	IsClosed() bool

	Publish(subject string, data []byte) error
}

Connection is an interface of event bus driver

type Dependency

type Dependency struct {
	Name            string
	EventSourceName string
	EventName       string
}

Dependency is a struct for dependency info of a sensor

type Driver

type Driver interface {
	Connect() (Connection, error)

	// SubscribeEventSources is used to subscribe multiple event source dependencies
	// Parameter - ctx, context
	// Parameter - conn, eventbus connection
	// Parameter - group, NATS Streaming queue group or Kafka consumer group
	// Parameter - closeCh, channel to indicate to close the subscription
	// Parameter - dependencyExpr, example: "(dep1 || dep2) && dep3"
	// Parameter - dependencies, array of dependencies information
	// Parameter - filter, a function used to filter the message
	// Parameter - action, a function to be triggered after all conditions meet
	SubscribeEventSources(ctx context.Context, conn Connection, group string, closeCh <-chan struct{}, dependencyExpr string, dependencies []Dependency, filter func(string, cloudevents.Event) bool, action func(map[string]cloudevents.Event)) error

	// Publish a message
	Publish(conn Connection, message []byte) error
}

Driver is an interface for event bus

func NewNATSStreaming

func NewNATSStreaming(url, clusterID, subject, clientID string, auth *Auth, logger *zap.SugaredLogger) Driver

NewNATSStreaming returns a nats streaming driver

Jump to

Keyboard shortcuts

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