Documentation ¶
Index ¶
- Variables
- type ConnectionNotificationType
- type Dispatcher
- type File
- type FileWatcher
- type ServerConnection
- func (s *ServerConnection) GetAddress() (address string)
- func (s *ServerConnection) GetBytesTransferred() (bytesTransferred uint64)
- func (s *ServerConnection) GetConnectionTime() (connectionTime time.Time)
- func (s *ServerConnection) GetFileSizeOnServer(filename string) (fileSize uint64)
- func (s *ServerConnection) GetFilesTransferred() (files []*File)
- func (s *ServerConnection) GetIndex() (index uint16)
- func (s *ServerConnection) GetPort() (port uint32)
- func (s *ServerConnection) MarshalZerologObject(e *zerolog.Event)
- type ServerNotification
- type ServerTransferJob
- type ServerTransferWorker
- type TorrxferClient
Constants ¶
This section is empty.
Variables ¶
var ConnectionNotificationStrings = map[ConnectionNotificationType]string{ ConnectionNotificationTypeConnected: "Connected", ConnectionNotificationTypeDisconnected: "Disconnected", ConnectionNotificationTypeFilesUpdated: "File Updated", ConnectionNotificationTypeQueryError: "Query Error", ConnectionNotificationTypeTransferError: "Transfer Error", ConnectionNotificationTypeCompleted: "Completed", }
ConnectionNotificationStrings String representation of ConnectionNotificationType iota
Functions ¶
This section is empty.
Types ¶
type ConnectionNotificationType ¶
type ConnectionNotificationType uint8
ConnectionNotificationType is an iota for all types of connection notifications
const ( // ConnectionNotificationTypeConnected Connected ConnectionNotificationTypeConnected ConnectionNotificationType = iota // ConnectionNotificationTypeDisconnected Disconnected ConnectionNotificationTypeDisconnected // ConnectionNotificationTypeFilesUpdated Bytes transferred for file ConnectionNotificationTypeFilesUpdated // ConnectionNotificationTypeCompleted File transfer completed ConnectionNotificationTypeCompleted // ConnectionNotificationTypeQueryError Query error from server ConnectionNotificationTypeQueryError // ConnectionNotificationTypeTransferError Transfer error from server ConnectionNotificationTypeTransferError // ConnectionNotificationTypeFatalError Fatal transfer error ConnectionNotificationTypeFatalError )
type Dispatcher ¶ added in v0.1.4
type Dispatcher struct {
// contains filtered or unexported fields
}
func NewDispatcher ¶ added in v0.1.4
func NewDispatcher(jobQueue <-chan ServerTransferJob, maxWorkers int) *Dispatcher
NewDispatcher creates, and returns a new Dispatcher object.
type File ¶
type File struct { Path string MediaPrefix string Size uint64 ModifiedTime time.Time WatchTime time.Time TransferTime time.Time }
File in the client package represents the clients view of a watched file
func NewClientFile ¶
NewClientFile parses a preset media root and a path to string and outputs the client file representation for the file path. This function should be used to tell the Torrxfer server what part of the file path should be used to generate its directory structure and what path from the client should be discarded Example: If the provided path is /home/user/foo/bar/file.txt and the directory structure under foo should be maintained on the server, mediaDirectoryRoot should be /home/user/foo. This will tell the server that under its own media folder it should create the directory bar and store file.txt there.
func (*File) GenerateRPCFile ¶
GenerateRPCFile creates an RPCFile representation from the current file
func (*File) MarshalText ¶
MarshalText converts the clientFile representation to a utf encoded byte array
func (*File) MarshalZerologObject ¶
MarshalZerologObject adds the file details to the current zerolog event
func (*File) UnmarshalText ¶
UnmarshalText takes a utf encoded byte array and builds a ClientFile object from it
type FileWatcher ¶
type FileWatcher interface { RegisterForFileNotifications() <-chan *File Close() }
FileWatcher provides notifications when changes occur on the provided watched directory
func NewFileWatcher ¶
func NewFileWatcher(directory string, mediaDirectoryRoot string) (FileWatcher, error)
NewFileWatcher starts watching the provided directory for any new writes and here-before unseen files If there is a new file, this will wait up to two minutes for any new writes, at which point it will
type ServerConnection ¶
ServerConnection contains all active data about a connection with a Torrxfer server
func (*ServerConnection) GetAddress ¶
func (s *ServerConnection) GetAddress() (address string)
GetAddress returns the address of the server
func (*ServerConnection) GetBytesTransferred ¶
func (s *ServerConnection) GetBytesTransferred() (bytesTransferred uint64)
GetBytesTransferred returns the total bytes transferred to the server in this session
func (*ServerConnection) GetConnectionTime ¶
func (s *ServerConnection) GetConnectionTime() (connectionTime time.Time)
GetConnectionTime returns the time when the server was connected
func (*ServerConnection) GetFileSizeOnServer ¶
func (s *ServerConnection) GetFileSizeOnServer(filename string) (fileSize uint64)
GetFileSizeOnServer returns the current number of bytes transferred for this file in this session
func (*ServerConnection) GetFilesTransferred ¶
func (s *ServerConnection) GetFilesTransferred() (files []*File)
GetFilesTransferred returns the files transferred to the server in this session
func (*ServerConnection) GetIndex ¶
func (s *ServerConnection) GetIndex() (index uint16)
GetIndex returns the index of the server for the client
func (*ServerConnection) GetPort ¶
func (s *ServerConnection) GetPort() (port uint32)
GetPort returns the port of the server
func (*ServerConnection) MarshalZerologObject ¶
func (s *ServerConnection) MarshalZerologObject(e *zerolog.Event)
MarshalZerologObject implements the zerolog Object Marshaller for easy connection detail logging
type ServerNotification ¶
type ServerNotification struct { NotificationType ConnectionNotificationType Error error Connection *ServerConnection SentFile *File LastSentSize uint64 }
ServerNotification is a struct that contains details about a notification from a server transfer action
type ServerTransferJob ¶ added in v0.1.4
type ServerTransferJob struct { ID uuid.UUID Delay time.Duration ServerConnection *ServerConnection File *File TransferNotifications chan ServerNotification }
ServerTransferJob holds the attributes needed to perform unit of work.
type ServerTransferWorker ¶ added in v0.1.4
type ServerTransferWorker struct {
// contains filtered or unexported fields
}
ServerTransferWorker performs the work necessary to transfer a file request to a server
func NewServerTransferWorker ¶ added in v0.1.4
func NewServerTransferWorker(id int, workerPool chan chan ServerTransferJob) ServerTransferWorker
NewServerTransferWorker creates takes a numeric id and a channel w/ worker pool.
type TorrxferClient ¶
type TorrxferClient interface { WatchDirectory(dirname, mediaDirectoryRoot string) error ConnectServer(server common.ServerConnectionConfig) (*ServerConnection, error) RegisterForConnectionNotifications() <-chan ServerNotification Run(*os.File) error }
TorrxferClient struct describes the client functionality for Torrxfer
func NewTorrxferClient ¶
func NewTorrxferClient() (c TorrxferClient)
NewTorrxferClient creates and instantiates a torrxfer client struct