socket

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: May 6, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Consumer

func Consumer(channel chan transmit.Serializable)

Consumer is a dummy setup to help test socket

func ProcessedFileHandler

func ProcessedFileHandler(socket Socket, conn net.Conn)

ProcessedFileHandler is a handler for a socket that receives processed files from the transformation step

func Producer

func Producer(channel chan transmit.Serializable)

Producer is a dummy setup to help test socket

func SendFileHandler

func SendFileHandler(socket Socket, conn net.Conn)

SendFileHandler is a handler function for a socket that sends files to the transformation step

Types

type ConnHandler

type ConnHandler func(Socket, net.Conn)

ConnHandler is a handler function ran in a goroutine upon a socket accepting a new connection

type Pipe

type Pipe struct {
	SocketFrom Socket
	SocketTo   Socket
	FromTarget chan transmit.Serializable
	ToTarget   chan transmit.Serializable
}

Pipe represents a bidirectional connection between an iterum sidecar and transformation step ToTarget and FromTarget refer to the channels in the two sockets Messages supposed to go towards Target can be put on ToTarget and message from the Target are put on FromTarget

func NewPipe

func NewPipe(fromFile, toFile string, fromChannel, toChannel chan transmit.Serializable, fromHandler, toHandler ConnHandler) Pipe

NewPipe creates and initiates a new Pipe

func (Pipe) Start

func (p Pipe) Start(wg *sync.WaitGroup)

Start calls start on both of the pipe's sockets

type Socket

type Socket struct {
	Listener net.Listener
	Channel  chan transmit.Serializable
	// contains filtered or unexported fields
}

Socket is a structure holding a listener, accepting connections Channel is a channel that external things can post messages on take from that are supposed to be sent to or from the connections

func NewSocket

func NewSocket(socketPath string, channel chan transmit.Serializable, handler ConnHandler) (s Socket, err error)

NewSocket sets up a listener at the given socketPath and links the passed channel with the given bufferSize. It returns an error on failure

func (Socket) Start

func (s Socket) Start(wg *sync.WaitGroup)

Start asychronously calls StartBlocking via Gorouting

func (Socket) StartBlocking

func (s Socket) StartBlocking()

StartBlocking enters an endless loop accepting connections and calling the handler function in a goroutine

func (*Socket) Stop added in v0.1.3

func (s *Socket) Stop() error

Stop tries to close the listener of the socket and returns an error on failure

Jump to

Keyboard shortcuts

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