Documentation
¶
Index ¶
- Variables
- func CreateNewFTPClient(hostname string, hostport int, username string, password string, ...) *ftpConnectionAndSession
- func DefaultFTPFilnameGenerator(data []byte, fileExtension string) (string, error)
- type BufferedConn
- type ConnectionAndSessionInstance
- type ConnectionInstance
- type ConnectionType
- type ErrorType
- type FTPFilenameGeneratorFunction
- type FileNameGeneration
- type Handler
- type ProcessStrategy
- type ReadFilePolicy
- type SecureConnectionOptions
- type Session
- type TCPClientConfiguration
- type TCPServerConfiguration
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultTCPClientSettings = TCPClientConfiguration{ Timeout: time.Second * 3, Deadline: time.Millisecond * 200, FlushBufferTimoutMs: 500, PollInterval: time.Second * 60, SessionAfterFirstByte: true, SessionInitationTimeout: time.Second * 0, SourceIP: "", }
View Source
var DefaultTCPServerSettings = TCPServerConfiguration{ Timeout: time.Second * 3, Deadline: time.Millisecond * 200, FlushBufferTimoutMs: 500, PollInterval: time.Second * 60, SessionAfterFirstByte: true, SessionInitiationTimeout: time.Second * 30, }
View Source
var ErrConnectionFailed = fmt.Errorf("connction error")
View Source
var ErrDeleteFile = fmt.Errorf("failed to delete file")
View Source
var ErrDownloadFileFailed = fmt.Errorf("donwload files failed")
View Source
var ErrExited = fmt.Errorf("server exited")
View Source
var ErrFtpLoginFailed = fmt.Errorf("FTP Login Failed")
View Source
var ErrListFilesFailed = fmt.Errorf("failed to access files for listing")
View Source
var ErrSendFileFailed = fmt.Errorf("sending file failed")
Functions ¶
func CreateNewFTPClient ¶
func CreateNewFTPClient(hostname string, hostport int, username string, password string, inputFilePath, inputFilePattern, outputFilePath string, outputFileExtension string, filenameGeneratorFunction FTPFilenameGeneratorFunction, processStrategy ProcessStrategy, lineBreak string, pollInterval time.Duration, ) *ftpConnectionAndSession
10-180 Seconds is good for a pollInterval depending on the server
Types ¶
type BufferedConn ¶
type BufferedConn struct { net.Conn // So that most methods are embedded // contains filtered or unexported fields }
-------------------------------------------------------------------------------------------- BufferedConn wrapping the net.Conn yet compatible for better reading performance and a peek preview. --------------------------------------------------------------------------------------------
func (BufferedConn) FirstByteOrError ¶
func (b BufferedConn) FirstByteOrError(howLong time.Duration) error
type ConnectionAndSessionInstance ¶
type ConnectionAndSessionInstance interface { Connect() error ConnectionInstance Session }
func CreateNewTCPClient ¶
func CreateNewTCPClient(hostname string, port int, lowLevelProtocol protocol.Implementation, proxy ConnectionType, timing ...TCPClientConfiguration) ConnectionAndSessionInstance
type ConnectionInstance ¶
type ConnectionInstance interface { // Send data directly from instance. This will not work if the instance Send(data [][]byte) (int, error) //Receive data directly from instance. This will not work if the instance handles many connections like TCP-Servers Receive() ([]byte, error) // Run - Main-Loop. Blocking.& Run(handler Handler) error // Stop the main-loop of the Run-handler Stop() // Retrieve a session by IP. Do not use this for a normal protocol conversion of a server... Can return nil FindSessionsByIp(ip string) []Session // Wait until the server is ready for connections. Useful at startup. Returns true when the server is ready WaitReady() bool }
func CreateNewTCPServerInstance ¶
func CreateNewTCPServerInstance(listeningPort int, protocolReceiveve protocol.Implementation, connectionType ConnectionType, maxConnections int, timingConfigs ...TCPServerConfiguration) ConnectionInstance
type ConnectionType ¶
type ConnectionType int
const ( NoLoadBalancer ConnectionType = 1 HAProxySendProxyV2 ConnectionType = 2 )
type ErrorType ¶
type ErrorType int
const ( ErrorConnect ErrorType = 1 ErrorSend ErrorType = 2 ErrorReceive ErrorType = 3 ErrorDisconnect ErrorType = 4 ErrorInternal ErrorType = 5 ErrorConnectionLimit ErrorType = 6 ErrorAccept ErrorType = 7 // error for Server ErrorMaxConnections ErrorType = 8 ErrorCreateSession ErrorType = 9 // server only ErrorConfiguration ErrorType = 10 // Error in configuration ErrorLogin ErrorType = 11 )
type FileNameGeneration ¶
type FileNameGeneration int
const ( Default FileNameGeneration = 1 TimeStamp FileNameGeneration = 1 )
type Handler ¶
type Handler interface { //DataReceived event is triggered whenever the underlying protocol delivered a complete block(file/transmission) of data DataReceived(session Session, data []byte, receiveTimestamp time.Time) error // Connected event is triggered when connection is established. For client as well as for servers. For clients in addition every time the connection had // to be reestablished. If this method returns anything other but null, the connections // is declined and the thread ends Connected(session Session) error // Disconnected event is triggered when connection // is terminated. //For Servers: when the client ends the session // For clients: when the only client connection ends (inc.eof) Disconnected(session Session) // Error is called from async process (Run) when // status messages regarding the connection is available Error(session Session, typeOfError ErrorType, err error) }
type ProcessStrategy ¶
type ProcessStrategy string
const PROCESS_STRATEGY_DELETE ProcessStrategy = "delete"
after processing delete the read file
const PROCESS_STRATEGY_DONOTHING ProcessStrategy = "donothing"
after processing do nothing with the file, even though it will get reprocessed on a restart
const PROCESS_STRATEGY_MOVE2SAVE ProcessStrategy = "move2save"
after processing move the file to save folder
type ReadFilePolicy ¶
type ReadFilePolicy int
const ( ReadAndLeaveFile ReadFilePolicy = 1 DeleteWhenRead ReadFilePolicy = 2 RenameWhenRead ReadFilePolicy = 3 )
type SecureConnectionOptions ¶
type SecureConnectionOptions struct {
PublicKey string
}
type TCPClientConfiguration ¶
type TCPClientConfiguration struct { Timeout time.Duration Deadline time.Duration FlushBufferTimoutMs int PollInterval time.Duration SessionAfterFirstByte bool SessionInitationTimeout time.Duration SourceIP string }
func (TCPClientConfiguration) SetSourceIP ¶
func (s TCPClientConfiguration) SetSourceIP(sourceIP string) TCPClientConfiguration
Click to show internal directories.
Click to hide internal directories.