Documentation ¶
Overview ¶
Package updatepipe implements utilities for serialization and transport of IMAP update objects between processes and machines.
Its main goal is provide maddy command with ability to properly notify the server about changes without relying on it to coordinate access in the first place (so maddy command can work without a running server or with a broken server instance).
Additionally, it can be used to transfer IMAP updates between replicated nodes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface { // EnableUpdatePipe enables the internal update pipe implementation. // The mode argument selects the pipe behavior. EnableUpdatePipe must be // called before the first call to the Updates() method. // // This method is idempotent. All calls after a successful one do nothing. EnableUpdatePipe(mode BackendMode) error }
The Backend interface is implemented by storage backends that support both updates serialization using the internal updatepipe.P implementation. To activate this implementation, EnableUpdatePipe should be called.
type BackendMode ¶
type BackendMode int
const ( // ModeReplicate configures backend to both send and receive updates over // the pipe. ModeReplicate BackendMode = iota // ModePush configures backend to send updates over the pipe only. // // If EnableUpdatePipe(ModePush) is called for backend, its Updates() // channel will never receive any updates. ModePush BackendMode = iota )
type P ¶
type P interface { // Listen starts the "pull" goroutine that reads updates from the pipe and // sends them to the channel. // // Usually it is not possible to call Listen multiple times for the same // pipe. // // Updates sent using the same UpdatePipe object using Push are not // duplicates to the channel passed to Listen. Listen(upds chan<- mess.Update) error // InitPush prepares the UpdatePipe to be used as updates source (Push // method). // // It is called implicitly on the first Push call, but calling it // explicitly allows to detect initialization errors early. InitPush() error // Push writes the update to the pipe. // // The update will not be duplicated if the UpdatePipe is also listening // for updates. Push(upd mess.Update) error Close() error }
The P interface represents the handle for a transport medium used for IMAP updates.
type PubSubPipe ¶ added in v0.6.0
func (*PubSubPipe) Close ¶ added in v0.6.0
func (p *PubSubPipe) Close() error
func (*PubSubPipe) InitPush ¶ added in v0.6.0
func (p *PubSubPipe) InitPush() error
func (*PubSubPipe) Listen ¶ added in v0.6.0
func (p *PubSubPipe) Listen(upds chan<- mess.Update) error
func (*PubSubPipe) Subscribe ¶ added in v0.6.0
func (p *PubSubPipe) Subscribe(key interface{})
func (*PubSubPipe) Unsubscribe ¶ added in v0.6.0
func (p *PubSubPipe) Unsubscribe(key interface{})
type UnixSockPipe ¶
type UnixSockPipe struct { SockPath string Log log.Logger // contains filtered or unexported fields }
UnixSockPipe implements the UpdatePipe interface by serializating updates to/from a Unix domain socket. Due to the way Unix sockets work, only one Listen goroutine can be running.
The socket is stream-oriented and consists of the following messages:
SENDER_ID;JSON_SERIALIZED_INTERNAL_OBJECT\n
And SENDER_ID is Process ID and UnixSockPipe address concated as a string. It is used to deduplicate updates sent to Push and recevied via Listen.
The SockPath field specifies the socket path to use. The actual socket is initialized on the first call to Listen or (Init)Push.
func (*UnixSockPipe) Close ¶
func (usp *UnixSockPipe) Close() error
func (*UnixSockPipe) InitPush ¶
func (usp *UnixSockPipe) InitPush() error