Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 (*Agent) ListenAndServe ¶
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 ¶
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.