Documentation ¶
Overview ¶
Package rinqamqp provides an AMQP-based Rinq implementation.
Index ¶
Examples ¶
Constants ¶
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 ¶
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 ¶
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