rinqamqp

package
v0.0.0-...-335d32b Latest Latest
Warning

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

Go to latest
Published: May 29, 2018 License: MIT Imports: 27 Imported by: 2

Documentation

Overview

Package rinqamqp provides an AMQP-based Rinq implementation.

Index

Examples

Constants

View Source
const (
	// DefaultDSN is the AMQP DSN to use when no other DSN is specified.
	DefaultDSN = "amqp://localhost"

	// DefaultPoolSize is the default size to use for channel pools.
	DefaultPoolSize = 20
)

Variables

This section is empty.

Functions

func Dial

func Dial(dsn string, opts ...options.Option) (rinq.Peer, error)

Dial connects to an AMQP-based Rinq network using the default dialer.

Example

This example demonstrates how to establish a peer on a Rinq network using the default configuration.

peer, err := Dial("amqp://localhost")
if err != nil {
	panic(err)
}
defer peer.Stop()

fmt.Printf("connected")
Output:

connected
Example (WithOptions)

This example demonstrates how to establish a peer on a Rinq network using custom options.

peer, err := Dial(
	"amqp://localhost",
	options.DefaultTimeout(10*time.Second),
)
if err != nil {
	panic(err)
}
defer peer.Stop()

fmt.Println("connected")
Output:

connected

func DialEnv

func DialEnv(opts ...options.Option) (rinq.Peer, error)

DialEnv connects to an AMQP-based Rinq network using the a dialer and peer options described by environment variables.

The AMQP-specific environment variables are listed below. If any variable is undefined, the default value is used. Additionally, Rinq peer options are obtained by calling options.FromEnv().

- RINQ_AMQP_DSN - RINQ_AMQP_HEARTBEAT (duration in milliseconds, non-zero) - RINQ_AMQP_CHANNELS (channel pool size, positive integer, non-zero) - RINQ_AMQP_CONNECTION_TIMEOUT (duration in milliseconds, non-zero)

Note that for consistency with other environment variables, RINQ_AMQP_HEARTBEAT is specified in milliseconds, but AMQP only supports 1-second resolution for heartbeats. The heartbeat value is ROUNDED UP to the nearest whole second.

Options defined by environment variables take precedence over those in the opts slice.

Types

type Dialer

type Dialer struct {
	// The minimum number of AMQP channels to keep open. If PoolSize is zero,
	// DefaultPoolSize is used.
	PoolSize uint

	// Configuration for the underlying AMQP connection.
	AMQPConfig amqp.Config
}

Dialer connects to an AMQP-based Rinq network, establishing the peer's unique identity on the network.

Example

This example demonstrates how to establish a peer on a Rinq network using a Dialer with a custom AMQP configuration.

dialer := &Dialer{}
dialer.AMQPConfig.Heartbeat = 1 * time.Minute

peer, err := dialer.Dial(
	context.Background(),
	"amqp://localhost",
)
if err != nil {
	panic(err)
}
defer peer.Stop()

fmt.Println("connected")
Output:

connected

func (*Dialer) Dial

func (d *Dialer) Dial(
	ctx context.Context,
	dsn string,
	o ...options.Option,
) (rinq.Peer, error)

Dial connects to an AMQP-based Rinq network using the specified context and configuration.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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