manager

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2019 License: BSD-3-Clause Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownProtocol           = verror.Register("v.io/x/ref/runtime/internal/flow/manager.UnknownProtocol", verror.NoRetry, "{1:}{2:} unknown protocol{:3}")
	ErrManagerClosed             = verror.Register("v.io/x/ref/runtime/internal/flow/manager.ManagerClosed", verror.NoRetry, "{1:}{2:} manager is already closed")
	ErrAcceptFailed              = verror.Register("v.io/x/ref/runtime/internal/flow/manager.AcceptFailed", verror.NoRetry, "{1:}{2:} accept failed{:3}")
	ErrCacheClosed               = verror.Register("v.io/x/ref/runtime/internal/flow/manager.CacheClosed", verror.NoRetry, "{1:}{2:} cache is closed")
	ErrConnKilledToFreeResources = verror.Register("v.io/x/ref/runtime/internal/flow/manager.ConnKilledToFreeResources", verror.NoRetry, "{1:}{2:} Connection killed to free resources.")
	ErrInvalidProxyResponse      = verror.Register("v.io/x/ref/runtime/internal/flow/manager.InvalidProxyResponse", verror.NoRetry, "{1:}{2:} Invalid proxy response{:3}")
	ErrManagerDialingSelf        = verror.Register("v.io/x/ref/runtime/internal/flow/manager.ManagerDialingSelf", verror.NoRetry, "{1:}{2:} manager cannot be used to dial itself")
	ErrListeningWithNullRid      = verror.Register("v.io/x/ref/runtime/internal/flow/manager.ListeningWithNullRid", verror.NoRetry, "{1:}{2:} manager cannot listen when created with NullRoutingID")
	ErrProxyResponse             = verror.Register("v.io/x/ref/runtime/internal/flow/manager.ProxyResponse", verror.NoRetry, "{1:}{2:} proxy returned{:3}")
	ErrNoBlessingsForPeer        = verror.Register("v.io/x/ref/runtime/internal/flow/manager.NoBlessingsForPeer", verror.NoRetry, "{1:}{2:} no blessings tagged for peer {3}, rejected:{4}{:5}")
	ErrConnNotInCache            = verror.Register("v.io/x/ref/runtime/internal/flow/manager.ConnNotInCache", verror.NoRetry, "{1:}{2:} connection to {3} not in cache")
)

Functions

func New

func New(
	ctx *context.T,
	rid naming.RoutingID,
	dhcpPublisher *pubsub.Publisher,
	channelTimeout time.Duration,
	idleExpiry time.Duration,
	authorizedPeers []security.BlessingPattern) flow.Manager

New creates a new flow manager.

func NewErrAcceptFailed

func NewErrAcceptFailed(ctx *context.T, err error) error

NewErrAcceptFailed returns an error with the ErrAcceptFailed ID.

func NewErrCacheClosed

func NewErrCacheClosed(ctx *context.T) error

NewErrCacheClosed returns an error with the ErrCacheClosed ID.

func NewErrConnKilledToFreeResources

func NewErrConnKilledToFreeResources(ctx *context.T) error

NewErrConnKilledToFreeResources returns an error with the ErrConnKilledToFreeResources ID.

func NewErrConnNotInCache

func NewErrConnNotInCache(ctx *context.T, remote string) error

NewErrConnNotInCache returns an error with the ErrConnNotInCache ID.

func NewErrInvalidProxyResponse

func NewErrInvalidProxyResponse(ctx *context.T, typ string) error

NewErrInvalidProxyResponse returns an error with the ErrInvalidProxyResponse ID.

func NewErrListeningWithNullRid

func NewErrListeningWithNullRid(ctx *context.T) error

NewErrListeningWithNullRid returns an error with the ErrListeningWithNullRid ID.

func NewErrManagerClosed

func NewErrManagerClosed(ctx *context.T) error

NewErrManagerClosed returns an error with the ErrManagerClosed ID.

func NewErrManagerDialingSelf

func NewErrManagerDialingSelf(ctx *context.T) error

NewErrManagerDialingSelf returns an error with the ErrManagerDialingSelf ID.

func NewErrNoBlessingsForPeer

func NewErrNoBlessingsForPeer(ctx *context.T, peerNames []string, rejected []security.RejectedBlessing, err error) error

NewErrNoBlessingsForPeer returns an error with the ErrNoBlessingsForPeer ID.

func NewErrProxyResponse

func NewErrProxyResponse(ctx *context.T, msg string) error

NewErrProxyResponse returns an error with the ErrProxyResponse ID.

func NewErrUnknownProtocol

func NewErrUnknownProtocol(ctx *context.T, protocol string) error

NewErrUnknownProtocol returns an error with the ErrUnknownProtocol ID.

Types

type CachedConn

type CachedConn interface {
	Status() conn.Status
	IsEncapsulated() bool
	IsIdle(*context.T, time.Duration) bool
	EnterLameDuck(*context.T) chan struct{}
	RemoteLameDuck() bool
	CloseIfIdle(*context.T, time.Duration) bool
	Close(*context.T, error)
	RemoteEndpoint() naming.Endpoint
	LocalEndpoint() naming.Endpoint
	RemoteBlessings() security.Blessings
	RemoteDischarges() map[string]security.Discharge
	RTT() time.Duration
	LastUsed() time.Time
	DebugString() string
}

CachedConn is the interface implemented by *conn.Conn that is used by ConnCache. We make the ConnCache API take this interface to make testing easier.

type ConnCache

type ConnCache struct {
	// contains filtered or unexported fields
}

ConnCache is a cache from (protocol, address) and (routingID) to a set of Conns. Multiple goroutines may invoke methods on the ConnCache simultaneously.

func NewConnCache

func NewConnCache(idleExpiry time.Duration) *ConnCache

NewConnCache creates a ConnCache with an idleExpiry for connections. If idleExpiry is zero, connections will never expire.

func (*ConnCache) Close

func (c *ConnCache) Close(ctx *context.T)

Close closes all connections in the cache.

func (*ConnCache) EnterLameDuckMode

func (c *ConnCache) EnterLameDuckMode(ctx *context.T)

EnterLameDuckMode lame ducks all connections and waits for the the remote end to acknowledge the lameduck.

func (*ConnCache) ExportStats

func (c *ConnCache) ExportStats(prefix string)

ExportStats exports cache information to the global stats.

func (*ConnCache) Find

func (c *ConnCache) Find(
	ctx *context.T,
	remote naming.Endpoint,
	auth flow.PeerAuthorizer,
) (conn CachedConn, names []string, rejected []security.RejectedBlessing, err error)

Find returns a Conn based on the input remoteEndpoint. nil is returned if there is no such Conn.

Find calls will block if the desired connections are currently being dialed. Find will return immediately if the given context is canceled.

func (*ConnCache) FindAllCached

func (c *ConnCache) FindAllCached(
	ctx *context.T,
	remote naming.Endpoint,
	auth flow.PeerAuthorizer) ([]CachedConn, error)

FindAllCached returns all Conns for the specified endpoint that are already in the cache.

func (*ConnCache) FindCached

func (c *ConnCache) FindCached(
	ctx *context.T,
	remote naming.Endpoint,
	auth flow.PeerAuthorizer) (conn CachedConn, names []string, rejected []security.RejectedBlessing, err error)

FindCached returns a Conn only if it's already in the cache.

func (*ConnCache) Insert

func (c *ConnCache) Insert(conn CachedConn, proxy bool) error

Insert adds conn to the cache, keyed by both (protocol, address) and (routingID). An error will be returned iff the cache has been closed.

func (*ConnCache) InsertWithRoutingID

func (c *ConnCache) InsertWithRoutingID(conn CachedConn, proxy bool) error

InsertWithRoutingID adds conn to the cache keyed only by conn's RoutingID.

func (*ConnCache) KillConnections

func (c *ConnCache) KillConnections(ctx *context.T, num int) error

KillConnections will closes at least num Conns in the cache. This is useful when the manager is approaching system FD limits.

The policy is as follows: (1) Remove undialable (closing/closed) conns from the cache, there is no point

in closing undialable connections to address a FD limit.

(2) Close and remove lameducked, expired connections from the cache,

counting non-proxied connections towards the removed FD count (num).

(3) LameDuck idle expired connections, killing them if num is still greater

than 0.

(4) Finally if 'num' hasn't been reached, remove the LRU remaining conns

until num is reached.

If num is greater than the number of connections in the cache, all cached connections will be closed and removed. KillConnections returns an error iff the cache is closed.

func (*ConnCache) Reserve

func (c *ConnCache) Reserve(ctx *context.T, remote naming.Endpoint) *Reservation

Reserve reserves the right to dial a remote endpoint.

func (*ConnCache) String

func (c *ConnCache) String() string

String returns a user friendly representation of the connections in the cache.

type Reservation

type Reservation struct {
	// contains filtered or unexported fields
}

Reservation represents the right to dial a connection. We only hand out one reservation for a given connection at a time.

func (*Reservation) Context

func (r *Reservation) Context() *context.T

Context returns the context that should be used to dial the new connection.

func (*Reservation) ProxyConn

func (r *Reservation) ProxyConn() CachedConn

ProxyConn returns a connection to a relevant proxy if it exists. Otherwise it returns nil and the reservation holder should dial the proxy if necessary.

func (*Reservation) Unreserve

func (r *Reservation) Unreserve(conn, proxyConn CachedConn, err error) error

Unreserve removes this reservation, and broadcasts waiting threads to continue with their halted Find call.

Jump to

Keyboard shortcuts

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