Documentation
¶
Index ¶
- Constants
- func InitPaths(conf *Conf, join func(...string) string, mkpath func(*string, bool) error) (err error)
- func SetDefault(def map[*string]string)
- type Binnable
- type Binned
- type ByteRange
- type Cached
- type ClientConf
- type ClientDirs
- type ClientManager
- type ClientState
- type ClientStatus
- type Conf
- type DBConf
- type DecodeClientID
- type DecodePartials
- type Dispatcher
- type EncodeClientID
- type File
- type FileCache
- type FileQueue
- type FileSource
- type GateKeeper
- type GateKeeperFactory
- type HTTPServer
- type Hashed
- type Logger
- type MappingConf
- type Open
- type Partial
- type Payload
- type PayloadDecoder
- type PayloadDecoderFactory
- type PayloadFactory
- type Pollable
- type Polled
- type Queue
- type Readable
- type ReceiveLogger
- type Received
- type RecentFile
- type Recover
- type RecoverTransmission
- type Recovered
- type Rename
- type RequestValidator
- type SendLogger
- type Sendable
- type Sent
- type ServerConf
- type ServerDirs
- type SourceConf
- type SourceState
- type TagConf
- type TargetConf
- type Throughput
- type Translate
- type Transmit
- type Validate
Constants ¶
const ( // OrderFIFO indicates first-in, first-out sorting OrderFIFO = "fifo" // OrderLIFO indicates last-in, first-out sorting OrderLIFO = "lifo" // OrderNone indicates ordering is not important OrderNone = "none" // OrderAlpha indicates alphabetic ordering OrderAlpha = "" )
const ( // DefLog is the default logs directory name DefLog = "logs" // DefLogMsg is the default log messages directory name // (appended to "logs") DefLogMsg = "messages" // DefLogOut is the default outgoing log messages directory name // (appended to "logs") DefLogOut = "outgoing_to" // DefLogIn is the default incoming log messages directory name // (appended to "logs") DefLogIn = "incoming_from" // DefOut is the default outgoing data directory name DefOut = "outgoing_to" // DefCache is the default cache directory name DefCache = ".sts" // DefStage is the default stage directory name DefStage = "stage" // DefFinal is the default final directory name DefFinal = "incoming_from" // MethodHTTP indicates HTTP transfer method MethodHTTP = "http" // DefaultPort is the default TCP port used for HTTP communication DefaultPort = 1992 )
const ( // ConfirmNone is the indicator that a file has not been confirmed. ConfirmNone = 0 // ConfirmFailed is the indicator that file confirmation failed. ConfirmFailed = 1 // ConfirmPassed is the indicator that file confirmation succeeded. ConfirmPassed = 2 // ConfirmWaiting is the indicator that file confirmation succeeded but its // predecessor has not been confirmed. ConfirmWaiting = 3 )
Variables ¶
This section is empty.
Functions ¶
func InitPaths ¶
func InitPaths(conf *Conf, join func(...string) string, mkpath func(*string, bool) error) (err error)
InitPaths will initialize all conf paths and use the provided root for resolving relative paths
func SetDefault ¶
SetDefault will take a map of string pointers and set the values to the corresponding string in the map if it is empty
Types ¶
type Binnable ¶
type Binnable interface {
Sendable
GetNextAlloc() (int64, int64)
AddAlloc(int64)
IsAllocated() bool
}
Binnable is the interface a file must implement to have a chunk be part of a sendable bin
type Binned ¶
type Binned interface {
GetName() string
GetRenamed() string
GetPrev() string
GetFileTime() time.Time
GetFileHash() string
GetFileSize() int64
// GetSendSize will almost always be the same as GetFileSize. The one
// exception is for files recovered where some portion of the file was
// sent earlier.
GetSendSize() int64
GetSlice() (int64, int64)
}
Binned is the interface for a single file chunk that is part of a payload
type ByteRange ¶
ByteRange is the JSON-encodable struct used by the Partial for tracking a a single byte range
type ClientConf ¶
type ClientConf struct {
Dirs *ClientDirs `yaml:"dirs" json:"dirs"`
Sources []*SourceConf `yaml:"sources" json:"sources"`
}
ClientConf is the struct for housing all outgoing configuration
func (*ClientConf) UnmarshalJSON ¶
func (conf *ClientConf) UnmarshalJSON(data []byte) (err error)
UnmarshalJSON implements the Unmarshaler interface for handling custom member(s) https://golang.org/pkg/encoding/json/#Unmarshal
func (*ClientConf) UnmarshalYAML ¶
func (conf *ClientConf) UnmarshalYAML( unmarshal func(interface{}) error, ) (err error)
UnmarshalYAML implements the Unmarshaler interface for handling custom member(s) https://godoc.org/gopkg.in/yaml.v2
type ClientDirs ¶
type ClientDirs struct {
Out string `yaml:"out" json:"out"`
OutFollow bool `yaml:"out-follow" json:"out-follow"`
Log string `yaml:"logs" json:"logs"`
LogOut string `yaml:"logs-out" json:"logs-out"`
LogMsg string `yaml:"logs-flow" json:"logs-flow"`
Cache string `yaml:"cache" json:"cache"`
}
ClientDirs is the struct for managing the outgoing directory configuration items
type ClientManager ¶
type ClientManager interface {
GetClientStatus(clientID, clientName, clientOS string) (ClientStatus, error)
GetClientConf(clientID string) (*ClientConf, error)
SetClientConfReceived(clientID string, when time.Time) error
SetClientState(clientID string, state ClientState) error
}
ClientManager is responsible for disseminating and collecting information about a client (sender)
type ClientState ¶
type ClientState struct {
When string `json:"when"`
Version string `json:"vers"`
GoVersion string `json:"go"`
BuildTime string `json:"built"`
IsActive bool `json:"active"`
IPAddrs []string `json:"ip"`
Messages []string `json:"msg"`
Sources map[string]SourceState `json:"sources"`
}
ClientState is the outer structure for a runner to communicate to the server its current state
type ClientStatus ¶
type ClientStatus uint
ClientStatus uses bitmasking to represent the status of a client
const ( // ClientIsDisabled indicates that transfer is to not occur ClientIsDisabled ClientStatus = 1 << iota // ClientIsApproved indicates that transfer should be enabled ClientIsApproved // ClientHasUpdatedConfiguration indicates, well, the updated configuration // should be retrieved ClientHasUpdatedConfiguration )
type Conf ¶
type Conf struct {
AgentKey string `yaml:"stackimpact" json:"stackimpact"`
Client *ClientConf `yaml:"OUT" json:"out"`
Server *ServerConf `yaml:"IN" json:"in"`
}
Conf is the outer struct for decoding a YAML config file
type DBConf ¶
type DBConf struct {
Host string `yaml:"host" json:"host"`
Port uint `yaml:"port" json:"port"`
User string `yaml:"user" json:"user"`
Pass string `yaml:"pass" json:"pass"`
Name string `yaml:"name" json:"name"`
ClientsTable string `yaml:"table-clients" json:"table-clients"`
DatasetsTable string `yaml:"table-datasets" json:"table-datasets"`
}
DBConf is the struct for defining a database connection
type DecodeClientID ¶
DecodeClientID converts a composite client ID into its original key and unique ID
type DecodePartials ¶
DecodePartials decodes the input reader into a slice of Partial instance pointers
type Dispatcher ¶
Dispatcher is the interface for broadcasting messages
type EncodeClientID ¶
EncodeClientID creates a decodable composite ID from a key and unique ID
type File ¶
type File interface {
GetPath() string
GetName() string
GetSize() int64
GetTime() time.Time
GetMeta() []byte
}
File is the most basic interface for a File object
type FileCache ¶
type FileCache interface {
Iterate(func(Cached) bool)
Get(string) Cached
Add(Hashed)
Done(name string, whileLocked func(Cached))
Reset(string)
Remove(string)
Persist() error
}
FileCache is the interface for caching a collection of files
type FileSource ¶
type FileSource interface {
Scan(func(File) bool) ([]File, time.Time, error)
GetOpener() Open
Remove(File) error
Sync(File) (File, error)
IsNotExist(error) bool
}
FileSource is the interface for reading and deleting from a store of file objects on the client (i.e. sending) side
type GateKeeper ¶
type GateKeeper interface {
Recover()
CleanNow()
Prune(time.Duration)
Ready() bool
Scan(version string) ([]byte, error)
Prepare(request []Binned)
Receive(*Partial, io.Reader) error
Received([]Binned) (nRecvd int)
GetFileStatus(relPath string, sent time.Time) int
Stop(bool)
}
GateKeeper is the interface for managing the "putting away" of files received on the server
type GateKeeperFactory ¶
type GateKeeperFactory func(source string) GateKeeper
GateKeeperFactory creates GateKeeper instances
type HTTPServer ¶
type HTTPServer struct {
Host string `yaml:"http-host" json:"http-host"`
Port int `yaml:"http-port" json:"http-port"`
PathPrefix string `yaml:"http-path-prefix" json:"http-path-prefix"`
TLSCertPath string `yaml:"http-tls-cert" json:"http-tls-cert"`
TLSKeyPath string `yaml:"http-tls-key" json:"http-tls-key"`
Compression int `yaml:"compress" json:"compress"`
ChanceOfSimulatedFailure float64 `yaml:"chance-of-simulated-failure" json:"chance-of-simulated-failure"`
}
HTTPServer is the struct for managing the incoming HTTP host
type Logger ¶
type Logger interface {
Debug(...interface{})
Info(...interface{})
Error(...interface{})
Recent(int) []string
}
Logger is the generic logging interface
type MappingConf ¶
MappingConf is the struct for indicating what path pattern should be mapped to a different target name based on the associated template string
func (*MappingConf) MarshalJSON ¶
func (m *MappingConf) MarshalJSON() ([]byte, error)
MarshalJSON implements Marshaler interface for handling custom member(s) https://golang.org/pkg/encoding/json/#Marshal
func (*MappingConf) UnmarshalJSON ¶
func (m *MappingConf) UnmarshalJSON(data []byte) (err error)
UnmarshalJSON implements the Unmarshaler interface for handling custom member(s) https://golang.org/pkg/encoding/json/#Unmarshal
func (*MappingConf) UnmarshalYAML ¶
func (m *MappingConf) UnmarshalYAML(unmarshal func(interface{}) error) (err error)
UnmarshalYAML implements the Unmarshaler interface for handling custom member(s): https://godoc.org/gopkg.in/yaml.v2
type Partial ¶
type Partial struct {
Name string `json:"path"`
Renamed string `json:"renamed"`
Prev string `json:"prev"`
Time marshal.NanoTime `json:"time"`
Size int64 `json:"size"`
Hash string `json:"hash"`
Source string `json:"src"`
Parts []*ByteRange `json:"parts"`
}
Partial is the JSON-encodable struct containing metadata for a single file on the receiving end
type Payload ¶
type Payload interface {
Add(Binnable) bool
Remove(Binned)
IsFull() bool
Split(nParts int) Payload
GetSize() int64
GetParts() []Binned
EncodeHeader() ([]byte, error)
GetEncoder() io.ReadCloser
GetStarted() time.Time
GetCompleted() time.Time
}
Payload is the interface to a slice of Binnables that can be read for transmission
type PayloadDecoder ¶
PayloadDecoder is the interface on the receiving side to a sent payload
type PayloadDecoderFactory ¶
type PayloadDecoderFactory func( metaLen int, pathSep string, payload io.Reader) (PayloadDecoder, error)
PayloadDecoderFactory creates a decoder instance to be used to parse a multipart byte stream with the metadata at the beginning
type PayloadFactory ¶
PayloadFactory creates a Payload instance based on the input max size (in bytes) and Open function
type Pollable ¶
type Pollable interface {
Sent
GetPrev() string // Needed in case the file needs to be resent
GetStarted() time.Time
}
Pollable is the interface a file must implement to be polled by the client for whether or not the server received the file successfully
type Queue ¶
type Queue struct {
Region string `yaml:"aws-region" json:"aws-region"`
Name string `yaml:"name" json:"name"`
}
Queue is the struct for managing an AWS queue resource
type ReceiveLogger ¶
type ReceiveLogger interface {
Parse(
handler func(name, renamed, hash string, size int64, t time.Time) bool,
after time.Time,
before time.Time) bool
Received(file Received)
WasReceived(
name, hash string,
after time.Time,
before time.Time) bool
}
ReceiveLogger is the interface for logging on the incoming side
type RecentFile ¶
type RecentFile struct {
Name string `json:"name"`
Rename string `json:"rename"`
Path string `json:"path"`
Hash string `json:"hash"`
Size int64 `json:"size"`
Time time.Time `json:"time"`
Sent bool `json:"sent"`
}
RecentFile is the data structure that encapsulates the state of a file used to communicate client state to the server
type Recover ¶
Recover is the function type for determining what partial files need to be sent since previous run
type RecoverTransmission ¶
RecoverTransmission is the function type for querying the server about a failed payload to determine which parts if any were successfully received in order to avoid duplication
type Recovered ¶
type Recovered interface {
Hashed
GetPrev() string
GetSendSize() int64
Allocate(int64) (int64, int64)
IsAllocated() bool
}
Recovered is the interface a file must implement to be recovered after a partial send
type RequestValidator ¶
RequestValidator validates an incoming request
type SendLogger ¶
type SendLogger interface {
Sent(Sent)
WasSent(name, hash string, after time.Time, before time.Time) bool
}
SendLogger is the interface for logging on the sending side
type ServerConf ¶
type ServerConf struct {
SourceControl *DBConf `yaml:"control" json:"control"`
Sources []string `yaml:"sources" json:"sources"`
Keys []string `yaml:"keys" json:"keys"`
Dirs *ServerDirs `yaml:"dirs" json:"dirs"`
Server *HTTPServer `yaml:"server" json:"server"`
Queue *Queue `yaml:"queue" json:"queue"`
PermitLogBuf bool `yaml:"log-buffering" json:"log-buffering"`
}
ServerConf is the struct for housing all incoming configuration
type ServerDirs ¶
type ServerDirs struct {
Log string `yaml:"logs" json:"logs"`
LogIn string `yaml:"logs-in" json:"logs-in"`
LogMsg string `yaml:"logs-flow" json:"logs-flow"`
Stage string `yaml:"stage" json:"stage"`
Final string `yaml:"final" json:"final"`
Serve string `yaml:"serve" json:"serve"`
}
ServerDirs is the struct for managing the incoming directory configuration items
type SourceConf ¶
type SourceConf struct {
Name string
OutDir string
LogDir string
Threads int
CacheAge time.Duration
MinAge time.Duration
MaxAge time.Duration
ScanDelay time.Duration
Timeout time.Duration
Compression int
StatInterval time.Duration
PollDelay time.Duration
PollInterval time.Duration
PollAttempts int
Target *TargetConf
Rename []*MappingConf
Tags []*TagConf
BinSize units.Base2Bytes
StatPayload bool
GroupBy *regexp.Regexp
IncludeHidden bool
Include []*regexp.Regexp
Ignore []*regexp.Regexp
ErrorBackoff float64
// contains filtered or unexported fields
}
SourceConf is the struct for managing the configuration of an outgoing client source
func (*SourceConf) GenMappingVars ¶
func (c *SourceConf) GenMappingVars() map[string]string
func (*SourceConf) MarshalJSON ¶
func (ss *SourceConf) MarshalJSON() ([]byte, error)
MarshalJSON implements Marshaler interface for handling custom member(s) https://golang.org/pkg/encoding/json/#Marshal
func (*SourceConf) UnmarshalJSON ¶
func (ss *SourceConf) UnmarshalJSON(data []byte) (err error)
UnmarshalJSON implements the Unmarshaler interface for handling custom member(s) https://golang.org/pkg/encoding/json/#Unmarshal
func (*SourceConf) UnmarshalYAML ¶
func (ss *SourceConf) UnmarshalYAML( unmarshal func(interface{}) error, ) (err error)
UnmarshalYAML implements the Unmarshaler interface for handling custom member(s) https://godoc.org/gopkg.in/yaml.v2
type SourceState ¶
type SourceState struct {
FoundCount int64 `json:"foundCnt"`
FoundSize int64 `json:"foundSize"`
QueueCount int64 `json:"qCnt"`
QueueSize int64 `json:"qSize"`
SentCount int64 `json:"sentCnt"`
SentSize int64 `json:"sentSize"`
Throughput Throughput `json:"throughput"`
RecentFiles []*RecentFile `json:"files"`
}
SourceState is the structure used to communicate to the server the current state of a single running source (an outgoing "client")
type TagConf ¶
type TagConf struct {
Priority int
Method string
Order string
Pattern *regexp.Regexp
Delete bool
LastDelay time.Duration
DeleteDelay time.Duration
// contains filtered or unexported fields
}
TagConf is the struct for managing configuration options for "tags" (groups) of files
func (*TagConf) MarshalJSON ¶
MarshalJSON implements Marshaler interface for handling custom member(s) https://golang.org/pkg/encoding/json/#Marshal
func (*TagConf) UnmarshalJSON ¶
UnmarshalJSON implements the Unmarshaler interface for handling custom member(s) https://golang.org/pkg/encoding/json/#Unmarshal
func (*TagConf) UnmarshalYAML ¶
UnmarshalYAML implements the Unmarshaler interface for handling custom member(s) https://godoc.org/gopkg.in/yaml.v2
type TargetConf ¶
type TargetConf struct {
Name string `yaml:"name" json:"name"`
Key string `yaml:"key" json:"key"`
Host string `yaml:"http-host" json:"http-host"`
PathPrefix string `yaml:"http-path-prefix" json:"http-path-prefix"`
TLSCertPath string `yaml:"http-tls-cert" json:"http-tls-cert"`
TLSCertBase64 string `yaml:"http-tls-cert-encoded" json:"http-tls-cert-encoded"`
}
TargetConf houses the configuration for the target host for a given source
type Throughput ¶
type Throughput struct {
Bytes int64 `json:"bytes"`
Seconds float64 `json:"secs"`
PctIdle float64 `json:"idle"`
}
Throughput is the structure used to keep track of bandwidth usage