nats

package
v2.0.0-alpha.3+incompa... Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestCreatesConnectionWhenOneDoesNotExistInPool

func TestCreatesConnectionWhenOneDoesNotExistInPool(t *testing.T)

func TestGetsConnectionFromPool

func TestGetsConnectionFromPool(t *testing.T)

Types

type Connection

type Connection interface {
	QueueSubscribe(
		subject,
		qgroup string,
		cb stan.MsgHandler,
		opts ...stan.SubscriptionOption) (stan.Subscription, error)
	Publish(subj string, data []byte) error
}

Connection defines the behaviour required for the Nats connection

type ConnectionMock

type ConnectionMock struct {
	// PublishFunc mocks the Publish method.
	PublishFunc func(subj string, data []byte) error

	// QueueSubscribeFunc mocks the QueueSubscribe method.
	QueueSubscribeFunc func(subject string, qgroup string, cb stan.MsgHandler, opts ...stan.SubscriptionOption) (stan.Subscription, error)
	// contains filtered or unexported fields
}

ConnectionMock is a mock implementation of Connection.

    func TestSomethingThatUsesConnection(t *testing.T) {

        // make and configure a mocked Connection
        mockedConnection := &ConnectionMock{
            PublishFunc: func(subj string, data []byte) error {
	               panic("TODO: mock out the Publish method")
            },
            QueueSubscribeFunc: func(subject string, qgroup string, cb stan.MsgHandler, opts ...stan.SubscriptionOption) (stan.Subscription, error) {
	               panic("TODO: mock out the QueueSubscribe method")
            },
        }

        // TODO: use mockedConnection in code that requires Connection
        //       and then make assertions.

    }

func (*ConnectionMock) Publish

func (mock *ConnectionMock) Publish(subj string, data []byte) error

Publish calls PublishFunc.

func (*ConnectionMock) PublishCalls

func (mock *ConnectionMock) PublishCalls() []struct {
	Subj string
	Data []byte
}

PublishCalls gets all the calls that were made to Publish. Check the length with:

len(mockedConnection.PublishCalls())

func (*ConnectionMock) QueueSubscribe

func (mock *ConnectionMock) QueueSubscribe(subject string, qgroup string, cb stan.MsgHandler, opts ...stan.SubscriptionOption) (stan.Subscription, error)

QueueSubscribe calls QueueSubscribeFunc.

func (*ConnectionMock) QueueSubscribeCalls

func (mock *ConnectionMock) QueueSubscribeCalls() []struct {
	Subject string
	Qgroup  string
	Cb      stan.MsgHandler
	Opts    []stan.SubscriptionOption
}

QueueSubscribeCalls gets all the calls that were made to QueueSubscribe. Check the length with:

len(mockedConnection.QueueSubscribeCalls())

type ConnectionPool

type ConnectionPool interface {
	GetConnection(server, clusterID string) (Connection, error)
}

type ConnectionPoolMock

type ConnectionPoolMock struct {
	// GetConnectionFunc mocks the GetConnection method.
	GetConnectionFunc func(server string, clusterID string) (Connection, error)
	// contains filtered or unexported fields
}

ConnectionPoolMock is a mock implementation of ConnectionPool.

    func TestSomethingThatUsesConnectionPool(t *testing.T) {

        // make and configure a mocked ConnectionPool
        mockedConnectionPool := &ConnectionPoolMock{
            GetConnectionFunc: func(server string, clusterID string) (Connection, error) {
	               panic("TODO: mock out the GetConnection method")
            },
        }

        // TODO: use mockedConnectionPool in code that requires ConnectionPool
        //       and then make assertions.

    }

func (*ConnectionPoolMock) GetConnection

func (mock *ConnectionPoolMock) GetConnection(server string, clusterID string) (Connection, error)

GetConnection calls GetConnectionFunc.

func (*ConnectionPoolMock) GetConnectionCalls

func (mock *ConnectionPoolMock) GetConnectionCalls() []struct {
	Server    string
	ClusterID string
}

GetConnectionCalls gets all the calls that were made to GetConnection. Check the length with:

len(mockedConnectionPool.GetConnectionCalls())

type StreamingConnectionPool

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

StreamingConnectionPool implements a connection pool for Nats Streaming

func NewStreamingConnectionPool

func NewStreamingConnectionPool() *StreamingConnectionPool

func (*StreamingConnectionPool) GetConnection

func (scp *StreamingConnectionPool) GetConnection(server, clusterID string) (Connection, error)

GetConnection returns a connection from the pool, if one does not exist it creates it

type StreamingProvider

type StreamingProvider struct {
	Server    string               `hcl:"server"`
	ClusterID string               `hcl:"cluster_id"`
	Queue     string               `hcl:"queue"`
	AuthBasic *providers.AuthBasic `hcl:"auth_basic,block"`
	AuthMTLS  *providers.AuthMTLS  `hcl:"auth_mtls,block"`
	// contains filtered or unexported fields
}

func NewStreamingProvider

func NewStreamingProvider(
	name, direction string,
	cp ConnectionPool,
	l logger.Logger) *StreamingProvider

func (*StreamingProvider) Direction

func (sp *StreamingProvider) Direction() string

func (*StreamingProvider) Listen

func (sp *StreamingProvider) Listen() (<-chan *providers.Message, error)

func (*StreamingProvider) Name

func (sp *StreamingProvider) Name() string

func (*StreamingProvider) Publish

Publish a message to the configured outbound queue

func (*StreamingProvider) Setup

func (sp *StreamingProvider) Setup() error

func (*StreamingProvider) Stop

func (sp *StreamingProvider) Stop() error

func (*StreamingProvider) Type

func (sp *StreamingProvider) Type() string

type Subscription

type Subscription interface {
	stan.Subscription
}

type SubscriptionMock

type SubscriptionMock struct {
	// CloseFunc mocks the Close method.
	CloseFunc func() error

	// UnsubscribeFunc mocks the Unsubscribe method.
	UnsubscribeFunc func() error
	// contains filtered or unexported fields
}

SubscriptionMock is a mock implementation of Subscription.

    func TestSomethingThatUsesSubscription(t *testing.T) {

        // make and configure a mocked Subscription
        mockedSubscription := &SubscriptionMock{
            CloseFunc: func() error {
	               panic("TODO: mock out the Close method")
            },
            UnsubscribeFunc: func() error {
	               panic("TODO: mock out the Unsubscribe method")
            },
        }

        // TODO: use mockedSubscription in code that requires Subscription
        //       and then make assertions.

    }

func (*SubscriptionMock) Close

func (mock *SubscriptionMock) Close() error

Close calls CloseFunc.

func (*SubscriptionMock) CloseCalls

func (mock *SubscriptionMock) CloseCalls() []struct {
}

CloseCalls gets all the calls that were made to Close. Check the length with:

len(mockedSubscription.CloseCalls())

func (*SubscriptionMock) Unsubscribe

func (mock *SubscriptionMock) Unsubscribe() error

Unsubscribe calls UnsubscribeFunc.

func (*SubscriptionMock) UnsubscribeCalls

func (mock *SubscriptionMock) UnsubscribeCalls() []struct {
}

UnsubscribeCalls gets all the calls that were made to Unsubscribe. Check the length with:

len(mockedSubscription.UnsubscribeCalls())

Jump to

Keyboard shortcuts

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