Documentation
¶
Index ¶
- func NewRNSClientMsg(operation NatsCommand) *nats.Msg
- func NewRNSReplyMsg(replyto *nats.Msg) *nats.Msg
- type Client
- type CloseOp
- type CloseResult
- type FileInfo
- type ListOp
- type ListResult
- type LoadOp
- type LoadResult
- type MkdirOp
- type MkdirResult
- type NatsCommand
- type OpenRepoOp
- type OpenRepoResult
- type RNSOptions
- func WithCredentials(credfile string) RNSOptions
- func WithLogger(log logadapter.Logger) RNSOptions
- func WithName(name string) RNSOptions
- func WithPingInterval(t time.Duration) RNSOptions
- func WithServer() RNSOptions
- func WithTLSOptions(tls *tls.Config) RNSOptions
- func WithUserPass(username, password string) RNSOptions
- type RNSServer
- type RNSServerImpl
- type RemoveOp
- type RemoveResult
- type ResticNatsClient
- func (rns *ResticNatsClient) ChunkReadRequestMsgWithContext(ctx context.Context, msg *nats.Msg) (*nats.Msg, error)
- func (rns *ResticNatsClient) ChunkSendReplyMsgWithContext(ctx context.Context, replyto *nats.Msg, msg *nats.Msg) error
- func (rns *ResticNatsClient) ChunkSendRequestMsgWithContext(ctx context.Context, msg *nats.Msg) (*nats.Msg, error)
- func (rns *ResticNatsClient) Close(ctx context.Context) (CloseResult, error)
- func (rns *ResticNatsClient) List(ctx context.Context, dir string, recursive bool) (ListResult, error)
- func (rns *ResticNatsClient) Load(ctx context.Context, dir string, filename string, length int, offset int64) (LoadResult, error)
- func (rns *ResticNatsClient) Mkdir(ctx context.Context, dir string) (MkdirResult, error)
- func (rns *ResticNatsClient) OpenRepo(ctx context.Context, hostname string) (OpenRepoResult, error)
- func (rns *ResticNatsClient) Remove(ctx context.Context, dir string, filename string) (RemoveResult, error)
- func (rns *ResticNatsClient) Save(ctx context.Context, dir string, filename string, rd io.Reader) (SaveResult, error)
- func (rns *ResticNatsClient) Stat(ctx context.Context, dir, filename string) (StatResult, error)
- type SaveOp
- type SaveResult
- type StatOp
- type StatResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewRNSClientMsg ¶
func NewRNSClientMsg(operation NatsCommand) *nats.Msg
NewRNSClientMsg Returns a New RNS Client Message (for each "Transaction")
func NewRNSReplyMsg ¶
func NewRNSReplyMsg(replyto *nats.Msg) *nats.Msg
NewRNSClientMsg Returns a New RNS Client Message (for each "Transaction")
Types ¶
type CloseResult ¶
type CloseResult struct { //Ok - if the command was scuccessful Ok bool `json:"ok"` //Err - Error, if any Err error }
CloseResult - The result of Closing a Repository
type FileInfo ¶
type FileInfo struct { //Name - The name fo the file Name string `json:"name"` //Size - The size of the file Size int64 `json:"size"` }
FileInfo - File Information returned for each file in a ListOp Command
type ListOp ¶
type ListOp struct { //Basedir - the Base Directory to list BaseDir string `json:"base_dir"` //Subdir - If we would recurse into subsdirectories Recurse bool `json:"recurse"` }
ListOp - List files in a directory (and optionally, subdirectories)
type ListResult ¶
type ListResult struct { //Ok - If the command was succesful Ok bool `json:"ok"` //FI - Slice of FileInfo for all files found FI []FileInfo `json:"fi"` //Err - Error, if any Err error }
ListResult - The result of listing files
type LoadOp ¶
type LoadOp struct { //Dir - The Directory to read the file from Dir string `json:"dir"` //Name - The name of the file to Load Name string `json:"name"` //Length - How much data to load from the file Length int `json:"length"` //Offset - The offset where we should start reading the file from Offset int64 `json:"offset"` }
LoadOp - Read a file from a respository
type LoadResult ¶
type LoadResult struct { //Ok - if the command was successful Ok bool `json:"ok"` //Data - slice of bytes contianing the file contents Data []byte `json:"data"` //Err - Error, if any Err error }
LoadResult - The result of loading a file
type MkdirOp ¶
type MkdirOp struct { //Dir the name of the directory to create Dir string `json:"dir"` }
MkdirOp - Make a Directory in the Repository
type MkdirResult ¶
type MkdirResult struct { //Ok - if the Mkdir Command was successful Ok bool `json:"ok"` //Err, if any Err error }
MkdirResult - THe result of Making a Directory
type NatsCommand ¶
type NatsCommand string
NatsCommand is the Command the packet represents.
const ( //NatsOpenCmd - Open a Repository NatsOpenCmd NatsCommand = "open" //NatsStatCmd - Stat a file on the Repository NatsStatCmd NatsCommand = "stat" //NatsMkdirCmd - Mkdir on the Repository NatsMkdirCmd NatsCommand = "mkdir" //NatsSaveCmd - Save a file to the respository NatsSaveCmd NatsCommand = "save" //NatsListCmd - List files in a Repository NatsListCmd NatsCommand = "list" //NatsLoadCmd - Load a file from a respository NatsLoadCmd NatsCommand = "load" //NatsRemoveCmd - Remove a file from a Repository NatsRemoveCmd NatsCommand = "remove" //NatsCloseCmd - Close a Repository NatsCloseCmd NatsCommand = "close" )
type OpenRepoOp ¶
type OpenRepoOp struct { //Bucket the Repository to open Bucket string `json:"bucket"` //Client Name Client string `json:"client"` //Host name Hostname string `json:"hostname"` }
OpenRepoOp - Open a Repository
type OpenRepoResult ¶
type OpenRepoResult struct { // Ok - If the Repository is successfully opened Ok bool `json:"ok"` // Err, if any Err error `json:"err"` //ClientID - The ClientID ClientID string `json:"clientid"` }
OpenRepoResult - The result of Opening a Repository
type RNSOptions ¶
type RNSOptions func(*ResticNatsClient) error
func WithCredentials ¶
func WithCredentials(credfile string) RNSOptions
func WithLogger ¶
func WithLogger(log logadapter.Logger) RNSOptions
func WithName ¶
func WithName(name string) RNSOptions
func WithPingInterval ¶
func WithPingInterval(t time.Duration) RNSOptions
func WithServer ¶
func WithServer() RNSOptions
func WithTLSOptions ¶
func WithTLSOptions(tls *tls.Config) RNSOptions
func WithUserPass ¶
func WithUserPass(username, password string) RNSOptions
type RNSServer ¶
type RNSServer struct {
// contains filtered or unexported fields
}
func NewRNSServer ¶
func NewRNSServer(impl RNSServerImpl, rnsclient *ResticNatsClient, log logadapter.Logger) (RNSServer, error)
type RNSServerImpl ¶
type RNSServerImpl interface { LookupClient(string) (Client, error) Open(context.Context, OpenRepoOp) (OpenRepoResult, Client, error) Stat(context.Context, Client, StatOp) (StatResult, error) Mkdir(context.Context, Client, MkdirOp) (MkdirResult, error) Save(context.Context, Client, SaveOp) (SaveResult, error) List(context.Context, Client, ListOp) (ListResult, error) Load(context.Context, Client, LoadOp) (LoadResult, error) Remove(context.Context, Client, RemoveOp) (RemoveResult, error) Close(context.Context, Client, CloseOp) (CloseResult, error) }
type RemoveOp ¶
type RemoveOp struct { //Dir - The Name of the directory where the file resides Dir string `json:"dir"` //Name - Name of the file to remove Name string `json:"name"` }
RemoveOp - Remove a file from the Repository
type RemoveResult ¶
type RemoveResult struct { //Ok - if the command was scuccessful Ok bool `json:"ok"` //Err - Error, if any Err error }
RemoveResult - The result of removing a file
type ResticNatsClient ¶
type ResticNatsClient struct { Conn *nats.Conn Encoder nats.Encoder // contains filtered or unexported fields }
func New ¶
func New(server url.URL, opts ...RNSOptions) (*ResticNatsClient, error)
func (*ResticNatsClient) ChunkReadRequestMsgWithContext ¶
func (rns *ResticNatsClient) ChunkReadRequestMsgWithContext(ctx context.Context, msg *nats.Msg) (*nats.Msg, error)
ChunkReadRequestMsgWithContext - Read a message from the Nats Client and if its chunked, * get the remaining chunks and reconstruct the message * ctx - Context * msg - The message we got * returns the actual reconstructed message, or a error
func (*ResticNatsClient) ChunkSendReplyMsgWithContext ¶
func (rns *ResticNatsClient) ChunkSendReplyMsgWithContext(ctx context.Context, replyto *nats.Msg, msg *nats.Msg) error
ChunkSendReplyMsgWithContext - send a reply to a message, chunking this reply if its Data exceeds the NATS server max payload length ctx - Context replyto The Message we are replying to msg the actual message we want to send log Custom Logger
func (*ResticNatsClient) ChunkSendRequestMsgWithContext ¶
func (rns *ResticNatsClient) ChunkSendRequestMsgWithContext(ctx context.Context, msg *nats.Msg) (*nats.Msg, error)
ChunkSendRequestMsgWithContext send a message and expect a reply back from the Reciever ctx - The Context to use conn - the Nats Client Connection msg - the message to send log - Custom Logger
func (*ResticNatsClient) Close ¶
func (rns *ResticNatsClient) Close(ctx context.Context) (CloseResult, error)
func (*ResticNatsClient) List ¶
func (rns *ResticNatsClient) List(ctx context.Context, dir string, recursive bool) (ListResult, error)
func (*ResticNatsClient) Load ¶
func (rns *ResticNatsClient) Load(ctx context.Context, dir string, filename string, length int, offset int64) (LoadResult, error)
func (*ResticNatsClient) Mkdir ¶
func (rns *ResticNatsClient) Mkdir(ctx context.Context, dir string) (MkdirResult, error)
func (*ResticNatsClient) OpenRepo ¶
func (rns *ResticNatsClient) OpenRepo(ctx context.Context, hostname string) (OpenRepoResult, error)
func (*ResticNatsClient) Remove ¶
func (rns *ResticNatsClient) Remove(ctx context.Context, dir string, filename string) (RemoveResult, error)
func (*ResticNatsClient) Save ¶
func (rns *ResticNatsClient) Save(ctx context.Context, dir string, filename string, rd io.Reader) (SaveResult, error)
func (*ResticNatsClient) Stat ¶
func (rns *ResticNatsClient) Stat(ctx context.Context, dir, filename string) (StatResult, error)
type SaveOp ¶
type SaveOp struct { //Dir - The Directory to save the file in Dir string `json:"dir"` //Name - The Name of the file to save Name string `json:"name"` //FileSize - the size of the entire file Filesize int `json:"size"` //Data - The actual file data Data []byte `json:"data"` }
SaveOp - Save a file to the respository
type SaveResult ¶
type SaveResult struct { //Ok - of the save command was successful Ok bool `json:"ok"` //Err - Error, if any Err error }
SaveResult - The result of saving a file