Circuit Self-managed infrastructure, programmatic monitoring and orchestration

Connecting to a circuit cluster

To use the Go client API to the circuit, start by importing the client package:

	import "github.com/gocircuit/circuit/client"

The first step of every circuit client application is connecting to a circuit cluster. There are two alternative methods for doing so.

Connecting to a specific server

If you want to connect the client to a specific circuit server with a known circuit address, then use

Dial(addr string, authkey []byte) *Client

Argument addr specifies the circuit server address (a string of the form circuit://…), whereas authkey should equal the authentication key for this cluster, or nil if the cluster does not use encryption and authentication.

Dial blocks until the connection is established and on success returns a client object, which implements the Anchor interface and represents the root of the anchor hierarchy.

If Dial is to fail, it will report an error by panicing.

Connecting by discovering a server

Alternatively, if the circuit cluster supports (multicast-based) discovery, you could use DialDiscover to first discover a random circuit server from the cluster and then connect to it:

DialDiscover(multicast string, authkey []byte) *Client

The argument multicast must equal the multicast discovery address for the circuit cluster.