Documentation ¶
Index ¶
- Constants
- Variables
- func IsUnavailableErr(err error) bool
- type Client
- func (c *Client) Backlog(ctx context.Context, from, to string, group uuid.UUID) (backlog []int, call callstat.Call, err error)
- func (c *Client) Close()
- func (c *Client) Config() (config EndpointConfig)
- func (c *Client) Report(ctx context.Context, server string, group uuid.UUID, ...) (data *ole.SafeArrayConversion, report string, call callstat.Call, err error)
- func (c *Client) UpdateConfig(config EndpointConfig)
- func (c *Client) Vector(ctx context.Context, server string, group uuid.UUID) (vector *versionvector.Vector, call callstat.Call, err error)
- type Endpoint
- func (e *Endpoint) Backlog(ctx context.Context, vector *versionvector.Vector) (backlog []int, call callstat.Call, err error)
- func (e *Endpoint) Close()
- func (e *Endpoint) Config() (config EndpointConfig)
- func (e *Endpoint) Report(ctx context.Context, group uuid.UUID, vector *versionvector.Vector, ...) (data *ole.SafeArrayConversion, report string, call callstat.Call, err error)
- func (e *Endpoint) State() (state EndpointState)
- func (e *Endpoint) UpdateConfig(config EndpointConfig)
- func (e *Endpoint) Vector(ctx context.Context, group uuid.UUID) (vector *versionvector.Vector, call callstat.Call, err error)
- type EndpointConfig
- type EndpointState
- type Reporter
Constants ¶
const ( // DefaultRecoveryInterval specifies the default recovery interval for // client instances. DefaultRecoveryInterval = time.Second * 30 )
Variables ¶
var ( // ErrDisconnected is returned when a server is offline. ErrDisconnected = errors.New("the server is disconnected or offline") // ErrClosed is returned from calls to a service or interface in the event // that the Close() function has already been called. ErrClosed = errors.New("interface is closing or already closed") // ErrUnresponsive is returned from calls to a service or interface when // the underlying remote procedure call stalls for an unreasonable length of // time. ErrUnresponsive = errors.New("the server is unresponsive") // ErrZeroWorkers is returned when zero workers are specified in a call to // NewLimiter. ErrZeroWorkers = errors.New("no workers were specified for the limiter") )
var DefaultEndpointConfig = EndpointConfig{ Caching: true, CacheDuration: time.Second * 30, Limiting: true, Limit: 1, OnlineReconnectionInterval: time.Minute * 30, OfflineReconnectionInterval: time.Minute * 2, AcceptableCallDuration: time.Second * 30, }
DefaultEndpointConfig provides a default set of endpoint configuration values.
Functions ¶
func IsUnavailableErr ¶
IsUnavailableErr returns true if the given error indicates that a server is disconnected or offline.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides a threadsafe and efficient means of querying DFSR backlog and report information. It maintains an expiring cache of version vectors and attempts to manage DFSR queries in such a way that they do not overburden the target servers.
Client maintains an internal map of DFSR endpoints and monitors their health. Queries against endpoints that are known to be offline will return a failure immediately.
func NewClient ¶
func NewClient() *Client
NewClient creates a new Client that is capable of querying DFSR members via the DFSR Helper protocol. The returned Client will use the configuration values present in DefaultEndpointConfiguration.
func NewClientWithConfig ¶
func NewClientWithConfig(config EndpointConfig) *Client
NewClientWithConfig creates a new Client that is capable of querying DFSR members via the DFSR Helper protocol. The returned Client will use the provided endpoint configuration values.
func (*Client) Backlog ¶
func (c *Client) Backlog(ctx context.Context, from, to string, group uuid.UUID) (backlog []int, call callstat.Call, err error)
Backlog returns the outgoing backlog from one DSFR member to another. The backlog of each replicated folder within the requested group is returned. The members are identified by their fully qualified domain names.
func (*Client) Close ¶
func (c *Client) Close()
Close will release any resources consumed by the Client.
func (*Client) Config ¶
func (c *Client) Config() (config EndpointConfig)
Config returns the current configuration of the client.
func (*Client) Report ¶
func (c *Client) Report(ctx context.Context, server string, group uuid.UUID, vector *versionvector.Vector, backlog, files bool) (data *ole.SafeArrayConversion, report string, call callstat.Call, err error)
Report generates a report for the requested replication group.
func (*Client) UpdateConfig ¶
func (c *Client) UpdateConfig(config EndpointConfig)
UpdateConfig updates the client configuration.
func (*Client) Vector ¶
func (c *Client) Vector(ctx context.Context, server string, group uuid.UUID) (vector *versionvector.Vector, call callstat.Call, err error)
Vector returns the current reference version vector of the requested replication group on the specified DFSR member. The member is identified by its fully qualified domain name.
type Endpoint ¶
type Endpoint struct {
// contains filtered or unexported fields
}
Endpoint manages a connection to a remote or local server that implements the DFSR Helper protocol. It monitors the health of the connection by checking the errors returned by all queries for RPC connection failures.
When a connection is determined to be offline the endpoint manager will proactively attempt to reestablish it on a configurable interval. While offline all queries will fail immediately.
The underlying connection is reset periodically even when the connection is healthy in order to release resources in the RPC layer of remote systems that are encumbered by memory leaks. The online reconnection interval is also configurable.
The zero value of an endpoint is not suitable for use. Endpoints should be created with a call to NewEndpoint().
When finished with an endpoint, it is necessary to call Close() to release any resources consumed by the endpoint and to stop monitoring the health of its connection.
func NewEndpoint ¶
func NewEndpoint(fqdn string, config EndpointConfig) *Endpoint
NewEndpoint creates a new endpoint and returns it without blocking. The returned endpoint will be initialized asynchronously in its own goroutine.
func (*Endpoint) Backlog ¶
func (e *Endpoint) Backlog(ctx context.Context, vector *versionvector.Vector) (backlog []int, call callstat.Call, err error)
Backlog returns the current backlog when compared against the given reference version vector.
func (*Endpoint) Close ¶
func (e *Endpoint) Close()
Close releases any resources consumed by the endpoint.
func (*Endpoint) Config ¶
func (e *Endpoint) Config() (config EndpointConfig)
Config returns the current configuration of the endpoint.
func (*Endpoint) Report ¶
func (e *Endpoint) Report(ctx context.Context, group uuid.UUID, vector *versionvector.Vector, backlog, files bool) (data *ole.SafeArrayConversion, report string, call callstat.Call, err error)
Report generates a report when compared against the reference version vector.
func (*Endpoint) State ¶
func (e *Endpoint) State() (state EndpointState)
State returns the current state of the endpoint.
func (*Endpoint) UpdateConfig ¶
func (e *Endpoint) UpdateConfig(config EndpointConfig)
UpdateConfig updates the endpoint configuration.
type EndpointConfig ¶
type EndpointConfig struct { Caching bool CacheDuration time.Duration Limiting bool Limit uint // Maximum number of simultaneous calls OnlineReconnectionInterval time.Duration // Time between connection attempts when endpoint is online OfflineReconnectionInterval time.Duration // Time between connection attempts when endpoint is offline AcceptableCallDuration time.Duration // Maximum amount of time a remote procedure call is allowed before it is considered unresponsive }
EndpointConfig desribes a set of endpoint configuration parameters.
Caching instructs the client to cache retrieved version vectors for a specified duration.
Limiting instructs the client to limit the maximum number of simultaneous workers that can talk to an endpoint.
type EndpointState ¶
type EndpointState struct { Err error Changed time.Time // Last time the state changed Updated time.Time // Last time the state was updated IdleSince time.Time // Last time an action was performed on the endpoint Calls calltracker.Value // Representation of outstanding calls }
EndpointState describes the current condition of an endpoint.
func (*EndpointState) Closed ¶
func (s *EndpointState) Closed() bool
Closed returns true if the state indicates that the endpoint has been closed.
func (*EndpointState) Online ¶
func (s *EndpointState) Online() bool
Online returns true if the state indicates that the endpoint is online.
func (*EndpointState) Unresponsive ¶
func (s *EndpointState) Unresponsive(threshold time.Duration) bool
Unresponsive returns true if the state indicates that the endpoint is online but not responding promptly to requests.
The provided theshold is the maximum amount of time that may elapse before a remote procedure call is considered unresponsive.
type Reporter ¶
type Reporter interface { Close() Vector(ctx context.Context, group uuid.UUID, tracker dfsr.Tracker) (vector *versionvector.Vector, call callstat.Call, err error) Backlog(ctx context.Context, vector *versionvector.Vector, tracker dfsr.Tracker) (backlog []int, call callstat.Call, err error) Report(ctx context.Context, group uuid.UUID, vector *versionvector.Vector, backlog, files bool) (data *ole.SafeArrayConversion, report string, call callstat.Call, err error) }
Reporter provides access to the system API for DFSR health reports.
All implementations of the Reporter interface must be threadsafe.
func NewCacher ¶
NewCacher adds an expiring vector cache to the given Reporter. The duration of cached values is specified by duration.
func NewLimiter ¶
NewLimiter adds a work pool to the given Reporter. The number of workers is specified by numWorkers.
The returned Reporter pushes queries onto work queues that are fed into work pools of a configurable number of workers. Its purpose is to limit the amount of work pressure that is exerted on a particular server.
func NewReporter ¶
NewReporter creates a new reporter. When done with a reporter it should be closed with a call to Close(). If New is successful it will return a reporter and error will be nil, otherwise the returned reporter will be nil and error will be non-nil.