tststan

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Docker repository.
	Repository = "nats-streaming"

	// Default tag.
	DefaultTag = "0.18-alpine"

	// Default cluster id.
	DefaultClusterId = "tststan"

	// Default container expire time.
	DefaultExpire uint = 120
)

Functions

This section is empty.

Types

type Options

type Options struct {
	// Tag of the repository. Default: DefaultTag.
	Tag string

	// The cluster id of the server. Default: DefaultClusterId.
	ClusterId string

	// Use FILE store if true and use MEMORY store otherwise.
	// NOTE: Not support SQL store in this test server.
	FileStore bool

	// If specified and FileStore is true, data will be stored in this host directory.
	HostDataPath string

	// If specified, the port 4222/tcp will be mapped to it. Default: random port.
	HostPort uint16

	// If specified, the port 8222/tcp will be mapped to it. Default: random port.
	HostMonPort uint16

	// Expire time (in seconds) of the container. Default: DefaultExpire.
	Expire uint

	// BaseRunOptions is the base options, will be overrided by above.
	BaseRunOptions dockertest.RunOptions
}

Options is options to run a nats streaming test server.

type Resource

type Resource struct {
	// Nats streaming server docker container.
	*dockertest.Resource

	// Actual options.
	Options
}

Resource represents a test nats streaming server.

func Run

func Run(opts *Options) (*Resource, error)

Run is equivalent to RunFromPool(nil, opts).

func RunFromPool

func RunFromPool(pool *dockertest.Pool, opts *Options) (*Resource, error)

RunFromPool runs a test nats streaming server. If pool is nil, tstsvc.DefaultPool() will be used. If opts is nil, the default options will be used.

func (*Resource) NatsClient

func (res *Resource) NatsClient(opts ...nats.Option) (*nats.Conn, error)

NatsClient returns a nats client of the embedded nats server of the test nats streaming server.

func (*Resource) NatsURL

func (res *Resource) NatsURL() string

NatsURL returns the nats url to connect to the nats streaming server.

func (*Resource) StanClient

func (res *Resource) StanClient(clientId string, opts ...stan.Option) (stan.Conn, error)

StanClient returns a stan client of the test nats streaming server identified by clientId.

Jump to

Keyboard shortcuts

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