1/*2Maddy Mail Server - Composable all-in-one email server.3Copyright © 2019-2020 Max Mazurov <fox.cpp@disroot.org>, Maddy Mail Server contributors45This program is free software: you can redistribute it and/or modify6it under the terms of the GNU General Public License as published by7the Free Software Foundation, either version 3 of the License, or8(at your option) any later version.910This program is distributed in the hope that it will be useful,11but WITHOUT ANY WARRANTY; without even the implied warranty of12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13GNU General Public License for more details.1415You should have received a copy of the GNU General Public License16along with this program. If not, see <https://www.gnu.org/licenses/>.17*/1819// Package updatepipe implements utilities for serialization and transport of20// IMAP update objects between processes and machines.21//22// Its main goal is provide maddy command with ability to properly notify the23// server about changes without relying on it to coordinate access in the24// first place (so maddy command can work without a running server or with a25// broken server instance).26//27// Additionally, it can be used to transfer IMAP updates between replicated28// nodes.29package updatepipe3031import (32 mess "github.com/foxcpp/go-imap-mess"33)3435// The P interface represents the handle for a transport medium used for IMAP36// updates.37type P interface {38 // Listen starts the "pull" goroutine that reads updates from the pipe and39 // sends them to the channel.40 //41 // Usually it is not possible to call Listen multiple times for the same42 // pipe.43 //44 // Updates sent using the same UpdatePipe object using Push are not45 // duplicates to the channel passed to Listen.46 Listen(upds chan<- mess.Update) error4748 // InitPush prepares the UpdatePipe to be used as updates source (Push49 // method).50 //51 // It is called implicitly on the first Push call, but calling it52 // explicitly allows to detect initialization errors early.53 InitPush() error5455 // Push writes the update to the pipe.56 //57 // The update will not be duplicated if the UpdatePipe is also listening58 // for updates.59 Push(upd mess.Update) error6061 Close() error62}