n

package
v0.0.0-...-fd2add7 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2016 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const Scheme = "circuit"

Variables

View Source
var ErrParse = errors.NewError("parse")

Functions

func Bind

func Bind(v System)

func ParseNetAddr

func ParseNetAddr(s string) (net.Addr, error)

Types

type Addr

type Addr interface {
	// NetAddr returns the underlying networking address of this endpoint.
	NetAddr() net.Addr

	// String returns an equivalent textual representation of the address.
	String() string

	// Returns a unique textual representation of the address, suitable to be used as a file name.
	FileName() string

	// WorkerID returns the worker ID of the underlying worker.
	WorkerID() WorkerID
}

Addr represents the identity of a unique remote worker. The implementing type must be registered with package encoding/gob.

func ParseAddr

func ParseAddr(s string) (Addr, error)

func ServerAddr

func ServerAddr() Addr

type Conn

type Conn interface {

	// Read reads the next value from the connection.
	Read() (interface{}, error)

	// Write writes the given value to the connection.
	Write(interface{}) error

	// Close closes the connection.
	Close() error

	// ...
	Abort(reason error)

	// Addr returns the address of the remote endpoint.
	Addr() Addr
}

Conn is a connection to a remote endpoint.

type Dialer

type Dialer interface {

	// Dial connects to the endpoint specified by addr and returns a respective connection object.
	Dial(addr Addr) (Conn, error)
}

Dialer is a device for initating connections to addressed remote endpoints.

type Listener

type Listener interface {

	// Accept returns the next incoming connection.
	Accept() Conn

	// Close closes the listening device.
	Close()

	// Addr returns the address of this endpoint.
	Addr() Addr
}

Listener is a device for accepting incoming connections.

type System

type System interface {
	NewTransport(workerID WorkerID, addr net.Addr, key []byte) Transport
	ParseNetAddr(s string) (net.Addr, error)
	ParseAddr(s string) (Addr, error)
}

System creates a new transport framework for the given local address

type Transport

type Transport interface {
	Dialer
	Listener
}

Transport cumulatively represents the ability to listen for connections and dial into remote endpoints.

func NewTransport

func NewTransport(workerID WorkerID, addr net.Addr, key []byte) Transport

NewTransport creates a new transport framework for the given local address.

type WorkerID

type WorkerID string

WorkerID represents the identity of a circuit worker process.

func ChooseWorkerID

func ChooseWorkerID() WorkerID

ChooseWorkerID returns a random worker ID.

func HashWorkerID

func HashWorkerID(s string) WorkerID

HashWorkerID hashes the unconstrained string s into a worker ID value.

func Int64WorkerID

func Int64WorkerID(src int64) WorkerID

func ParseOrHashWorkerID

func ParseOrHashWorkerID(s string) WorkerID

ParseOrHashWorkerID tries to parse the string s as a canonical worker ID representation. If it fails, it treats s as an unconstrained string and hashes it to a worker ID value. In either case, it returns a WorkerID value.

func ParseWorkerID

func ParseWorkerID(s string) (WorkerID, error)

ParseWorkerID parses the string s for a canonical representation of a worker ID and returns a corresponding WorkerID value.

func UInt64WorkerID

func UInt64WorkerID(src uint64) WorkerID

func (WorkerID) String

func (r WorkerID) String() string

String returns a cononical string representation of this worker ID.

Jump to

Keyboard shortcuts

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