Documentation ¶
Overview ¶
package filewatcherbasedipc is used to establish IPC between master and workers using files.
package filewatcherbasedipc is used to establish IPC between master and workers using files.
Index ¶
- func IsFileWatcherChannelPresent(identity identity.IAgentIdentity, channelName string) (bool, error)
- func NewFileWatcherChannel(logger log.T, mode Mode, name string, shouldReadRetry bool) (*fileWatcherChannel, error)
- func RemoveFileWatcherChannel(identity identity.IAgentIdentity, channelName string) error
- type IPCChannel
- type Mode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsFileWatcherChannelPresent ¶
func IsFileWatcherChannelPresent(identity identity.IAgentIdentity, channelName string) (bool, error)
IsFileWatcherChannelPresent checks whether the file watcher channel is present or not
func NewFileWatcherChannel ¶
func NewFileWatcherChannel(logger log.T, mode Mode, name string, shouldReadRetry bool) (*fileWatcherChannel, error)
TODO make this constructor private
Create a file channel, a file channel is identified by its unique name name is the path where the watcher directory is created Only Master channel has the privilege to remove the dir at close time shouldReadRetry - is this flag is set to true, it will use fileReadWithRetry function to read
func RemoveFileWatcherChannel ¶
func RemoveFileWatcherChannel(identity identity.IAgentIdentity, channelName string) error
RemoveFileWatcherChannel removes the channel folder specific to the command
Types ¶
type IPCChannel ¶
type IPCChannel interface { // Send sends a raw json datagram to the channel, return when send is "complete" -- message is dropped to the persistent layer Send(string) error // GetMessage receives a datagram, the go channel on the other end is closed when channel is closed GetMessage() <-chan string //Close safely release all in memory resources -- drain the sending/receiving/queue and GetMessage() go channel, channel is reusable after close Close() //Destroy destroys the persistent channel transport, channel is no longer reusable after destroy Destroy() // CleanupOwnModeFiles cleans up it own mode files CleanupOwnModeFiles() // GetPath returns IPC filepath GetPath() string }
IPCChannel is defined as a persistent interface for raw json datagram transmission, it is designed to adopt both file ad named pipe
func CreateFileWatcherChannel ¶
func CreateFileWatcherChannel(log log.T, identity identity.IAgentIdentity, mode Mode, filename string, shouldReadRetry bool) (IPCChannel, error, bool)
find the folder named as "documentID" under the default root dir if not found, create a new filechannel under the default root dir return the channel and the found flag shouldReadRetry - is this flag is set to true, it will use fileReadWithRetry function to read