channel

package
v0.0.0-...-a9ed6da Latest Latest
Warning

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

Go to latest
Published: May 7, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFileWatcherChannel

func NewFileWatcherChannel(logger log.T, mode Mode, name string) (*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

Types

type Channel

type Channel interface {
	//send a raw json datagram to the channel, return when send is "complete" -- message is dropped to the persistent layer
	Send(string) error
	//receive a dategram, the go channel on the other end is closed when channel is closed
	GetMessage() <-chan string
	//safely release all in memory resources -- drain the sending/receiving/queue and GetMessage() go channel, channel is reusable after close
	Close()
	//destroy the persistent channel transport, channel is no longer reusable after destroy
	Destroy()
}

Channel is defined as a persistent interface for raw json datagram transmission, it is designed to adopt both file ad named pipe

func CreateFileChannel

func CreateFileChannel(log log.T, mode Mode, filename string) (Channel, 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

type Mode

type Mode string
const (
	ModeMaster Mode = "master"
	ModeWorker Mode = "worker"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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