publisher

package
v0.0.0-...-6e3bf65 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2018 License: MIT Imports: 8 Imported by: 2

Documentation

Overview

Package publisher contains a NATS publisher implementation build around the lower level NATS code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockPublisher

type MockPublisher struct {
	Available        bool
	ConnectWasCalled bool
	LastMsg          *message.Message
	RelayedCount     int
}

func (*MockPublisher) BreakerOff

func (m *MockPublisher) BreakerOff()

func (*MockPublisher) BreakerOn

func (m *MockPublisher) BreakerOn()

func (*MockPublisher) Connect

func (m *MockPublisher) Connect() error

func (*MockPublisher) IsAvailable

func (m *MockPublisher) IsAvailable() bool

func (*MockPublisher) RelayMessage

func (m *MockPublisher) RelayMessage(msg *message.Message)

func (*MockPublisher) Shutdown

func (m *MockPublisher) Shutdown()

type Publisher

type Publisher interface {
	Connect() error
	BreakerOn()
	BreakerOff()
	IsAvailable() bool
	RelayMessage(*message.Message)
	Shutdown()
}

A Publisher is an outlet for a Heka message that supports a circuit breaker and connection management.

type StanPublisher

type StanPublisher struct {
	NatsUrl         string
	ClusterId       string
	ClientId        string
	Subject         string
	Stats           *expvar.Map
	ConnectHoldDown time.Duration
	// contains filtered or unexported fields
}

A StanPublisher is a NATS Publisher with connection management, retries, and a circuit breaker that can be flipped while a connection can't be established.

func (*StanPublisher) BreakerOff

func (s *StanPublisher) BreakerOff()

BreakerOff flips the circuit breaker to off so that we can process any new incoming messages.

func (*StanPublisher) BreakerOn

func (s *StanPublisher) BreakerOn()

first message that has an issue because we don't actively manage the NATS connection.

func (*StanPublisher) Connect

func (s *StanPublisher) Connect() error

Connect is the main method, used to connect the StanPublisher to the specified NATS stream.

func (*StanPublisher) IsAvailable

func (s *StanPublisher) IsAvailable() bool

IsAvailable is used to see if the circuit breaker has been flipped off. This is used by consuming code that needs to know if the StanPublisher is ready to receive a new message or not, without waiting for a timeout.

func (*StanPublisher) RelayMessage

func (s *StanPublisher) RelayMessage(msg *message.Message)

RelayMessage publishes a message to NATS streaming. It is blocking and can hold onto the goroutine for several seconds so it should be run only where that won't cause any performance issues.

func (*StanPublisher) Shutdown

func (s *StanPublisher) Shutdown()

Shutdown will clean up after the publisher and close open connections

Jump to

Keyboard shortcuts

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