pubsub

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPConfig added in v1.0.1

type HTTPConfig struct {
	// Port to listen on
	Port int
	// Path for HTTP broadast
	Path string
	// Secret token to authorize requests
	Secret string
}

HTTPConfig contains HTTP pubsub adapter configuration

func NewHTTPConfig added in v1.0.1

func NewHTTPConfig() HTTPConfig

NewHTTPConfig builds a new config for HTTP pub/sub

type HTTPSubscriber added in v1.0.1

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

HTTPSubscriber represents HTTP pub/sub

func NewHTTPSubscriber added in v1.0.1

func NewHTTPSubscriber(node Handler, config *HTTPConfig) *HTTPSubscriber

NewHTTPSubscriber builds a new HTTPSubscriber struct

func (*HTTPSubscriber) Handler added in v1.0.1

func (s *HTTPSubscriber) Handler(w http.ResponseWriter, r *http.Request)

Handler processes HTTP requests

func (*HTTPSubscriber) Shutdown added in v1.0.1

func (s *HTTPSubscriber) Shutdown() error

Shutdown stops the HTTP server

func (*HTTPSubscriber) Start added in v1.0.1

func (s *HTTPSubscriber) Start(done chan (error)) error

Start creates an HTTP server or attaches a handler to the existing one

type Handler added in v1.1.4

type Handler interface {
	HandlePubSub(json []byte)
}

type NATSConfig added in v1.2.2

type NATSConfig struct {
	Servers              string
	Channel              string
	DontRandomizeServers bool
}

func NewNATSConfig added in v1.2.2

func NewNATSConfig() NATSConfig

type NATSSubscriber added in v1.2.2

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

func NewNATSSubscriber added in v1.2.2

func NewNATSSubscriber(node Handler, c *NATSConfig) *NATSSubscriber

func (*NATSSubscriber) Shutdown added in v1.2.2

func (s *NATSSubscriber) Shutdown() error

func (*NATSSubscriber) Start added in v1.2.2

func (s *NATSSubscriber) Start(done chan (error)) error

type RedisConfig added in v1.0.1

type RedisConfig struct {
	// Redis instance URL or master name in case of sentinels usage
	URL string
	// Redis channel to subscribe to
	Channel string
	// List of Redis Sentinel addresses
	Sentinels string
	// Redis Sentinel discovery interval (seconds)
	SentinelDiscoveryInterval int
	// Redis keepalive ping interval (seconds)
	KeepalivePingInterval int
	// Whether to check server's certificate for validity (in case of rediss:// protocol)
	TLSVerify bool
}

RedisConfig contains Redis pubsub adapter configuration

func NewRedisConfig added in v1.0.1

func NewRedisConfig() RedisConfig

NewRedisConfig builds a new config for Redis pubsub

type RedisSubscriber

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

RedisSubscriber contains information about Redis pubsub connection

func NewRedisSubscriber

func NewRedisSubscriber(node Handler, config *RedisConfig) *RedisSubscriber

NewRedisSubscriber returns new RedisSubscriber struct

func (*RedisSubscriber) Shutdown added in v1.0.1

func (s *RedisSubscriber) Shutdown() error

Shutdown is no-op for Redis

func (*RedisSubscriber) Start

func (s *RedisSubscriber) Start(done chan (error)) error

Start connects to Redis and subscribes to the pubsub channel if sentinels is set it gets the the master address first

type Subscriber added in v1.0.1

type Subscriber interface {
	Start(done chan (error)) error
	Shutdown() error
}

Subscriber is responsible for receiving broadcast messages and sending them to hub

func NewSubscriber added in v1.0.1

func NewSubscriber(node Handler, adapter string, redis *RedisConfig, http *HTTPConfig, nats *NATSConfig) (Subscriber, error)

NewSubscriber creates an instance of the provided adapter

Jump to

Keyboard shortcuts

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