agent

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrServerClosed = errors.New("agent: Server closed")

ErrServerClosed is returned by the Agent's ListenAndServe methods after a call to Shutdown or Close.

Functions

This section is empty.

Types

type Agent

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

Agent listen for request and dispatch it to a target

func NewAgent

func NewAgent(options *config.Options) *Agent

NewAgent allocates and returns a new Agent.

func (*Agent) ListenAndServe

func (a *Agent) ListenAndServe() error

ListenAndServe listens on the mercure HUB endpoint and then handle requests on stream.

ListenAndServe always returns a non-nil error. After Shutdown or Close, the returned error is ErrServerClosed.

func (*Agent) RegisterOnShutdown

func (a *Agent) RegisterOnShutdown(f func())

RegisterOnShutdown registers a function to call on Shutdown. This function should start protocol-specific graceful shutdown, but should not wait for shutdown to complete.

func (*Agent) Shutdown

func (a *Agent) Shutdown() error

Shutdown gracefully shuts down the agent without interrupting any active event. Shutdown works by closing stream.

When Shutdown is called, ListenAndServe immediately return ErrServerClosed. Make sure the program doesn't exit and waits instead for Shutdown to return.

Once Shutdown has been called on a server, it may not be reused; future calls to methods such as Serve will return ErrServerClosed.

Jump to

Keyboard shortcuts

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