protocol

package
v0.8.19 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2014 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package protocol implements the Block Exchange Protocol.

Index

Constants

View Source
const (
	FlagDeleted    uint32 = 1 << 12
	FlagInvalid           = 1 << 13
	FlagDirectory         = 1 << 14
	FlagNoPermBits        = 1 << 15
)
View Source
const (
	FlagShareTrusted  uint32 = 1 << 0
	FlagShareReadOnly        = 1 << 1
	FlagShareBits            = 0x000000ff
)
View Source
const BlockSize = 128 * 1024

Variables

View Source
var (
	ErrClusterHash = fmt.Errorf("configuration error: mismatched cluster hash")
	ErrClosed      = errors.New("connection closed")
)

Functions

func HasPermissionBits added in v0.8.10

func HasPermissionBits(bits uint32) bool

func IsDeleted added in v0.8.10

func IsDeleted(bits uint32) bool

func IsDirectory added in v0.8.10

func IsDirectory(bits uint32) bool

func IsInvalid added in v0.8.10

func IsInvalid(bits uint32) bool

func TotalInOut added in v0.8.10

func TotalInOut() (uint64, uint64)

Types

type BlockInfo

type BlockInfo struct {
	Size uint32
	Hash []byte // max:64
}

func (*BlockInfo) DecodeXDR added in v0.6.0

func (o *BlockInfo) DecodeXDR(r io.Reader) error

func (BlockInfo) EncodeXDR added in v0.6.0

func (o BlockInfo) EncodeXDR(w io.Writer) (int, error)

func (BlockInfo) MarshalXDR added in v0.6.0

func (o BlockInfo) MarshalXDR() []byte

func (*BlockInfo) UnmarshalXDR added in v0.6.0

func (o *BlockInfo) UnmarshalXDR(bs []byte) error

type ClusterConfigMessage added in v0.8.0

type ClusterConfigMessage struct {
	ClientName    string       // max:64
	ClientVersion string       // max:64
	Repositories  []Repository // max:64
	Options       []Option     // max:64
}

func (*ClusterConfigMessage) DecodeXDR added in v0.8.0

func (o *ClusterConfigMessage) DecodeXDR(r io.Reader) error

func (ClusterConfigMessage) EncodeXDR added in v0.8.0

func (o ClusterConfigMessage) EncodeXDR(w io.Writer) (int, error)

func (ClusterConfigMessage) MarshalXDR added in v0.8.0

func (o ClusterConfigMessage) MarshalXDR() []byte

func (*ClusterConfigMessage) UnmarshalXDR added in v0.8.0

func (o *ClusterConfigMessage) UnmarshalXDR(bs []byte) error

type Connection

type Connection interface {
	ID() string
	Index(repo string, files []FileInfo)
	Request(repo string, name string, offset int64, size int) ([]byte, error)
	ClusterConfig(config ClusterConfigMessage)
	Statistics() Statistics
}

func NewConnection

func NewConnection(nodeID string, reader io.Reader, writer io.Writer, receiver Model) Connection

type FileInfo

type FileInfo struct {
	Name     string // max:1024
	Flags    uint32
	Modified int64
	Version  uint64
	Blocks   []BlockInfo // max:100000
}

func (*FileInfo) DecodeXDR added in v0.6.0

func (o *FileInfo) DecodeXDR(r io.Reader) error

func (FileInfo) EncodeXDR added in v0.6.0

func (o FileInfo) EncodeXDR(w io.Writer) (int, error)

func (FileInfo) MarshalXDR added in v0.6.0

func (o FileInfo) MarshalXDR() []byte

func (*FileInfo) UnmarshalXDR added in v0.6.0

func (o *FileInfo) UnmarshalXDR(bs []byte) error

type IndexMessage added in v0.6.0

type IndexMessage struct {
	Repository string     // max:64
	Files      []FileInfo // max:1000000
}

func (*IndexMessage) DecodeXDR added in v0.6.0

func (o *IndexMessage) DecodeXDR(r io.Reader) error

func (IndexMessage) EncodeXDR added in v0.6.0

func (o IndexMessage) EncodeXDR(w io.Writer) (int, error)

func (IndexMessage) MarshalXDR added in v0.6.0

func (o IndexMessage) MarshalXDR() []byte

func (*IndexMessage) UnmarshalXDR added in v0.6.0

func (o *IndexMessage) UnmarshalXDR(bs []byte) error

type Model

type Model interface {
	// An index was received from the peer node
	Index(nodeID string, repo string, files []FileInfo)
	// An index update was received from the peer node
	IndexUpdate(nodeID string, repo string, files []FileInfo)
	// A request was made by the peer node
	Request(nodeID string, repo string, name string, offset int64, size int) ([]byte, error)
	// A cluster configuration message was received
	ClusterConfig(nodeID string, config ClusterConfigMessage)
	// The peer node closed the connection
	Close(nodeID string, err error)
}

type Node added in v0.8.0

type Node struct {
	ID    string // max:64
	Flags uint32
}

func (*Node) DecodeXDR added in v0.8.0

func (o *Node) DecodeXDR(r io.Reader) error

func (Node) EncodeXDR added in v0.8.0

func (o Node) EncodeXDR(w io.Writer) (int, error)

func (Node) MarshalXDR added in v0.8.0

func (o Node) MarshalXDR() []byte

func (*Node) UnmarshalXDR added in v0.8.0

func (o *Node) UnmarshalXDR(bs []byte) error

type Option added in v0.6.0

type Option struct {
	Key   string // max:64
	Value string // max:1024
}

func (*Option) DecodeXDR added in v0.6.0

func (o *Option) DecodeXDR(r io.Reader) error

func (Option) EncodeXDR added in v0.6.0

func (o Option) EncodeXDR(w io.Writer) (int, error)

func (Option) MarshalXDR added in v0.6.0

func (o Option) MarshalXDR() []byte

func (*Option) UnmarshalXDR added in v0.6.0

func (o *Option) UnmarshalXDR(bs []byte) error

type Repository added in v0.8.0

type Repository struct {
	ID    string // max:64
	Nodes []Node // max:64
}

func (*Repository) DecodeXDR added in v0.8.0

func (o *Repository) DecodeXDR(r io.Reader) error

func (Repository) EncodeXDR added in v0.8.0

func (o Repository) EncodeXDR(w io.Writer) (int, error)

func (Repository) MarshalXDR added in v0.8.0

func (o Repository) MarshalXDR() []byte

func (*Repository) UnmarshalXDR added in v0.8.0

func (o *Repository) UnmarshalXDR(bs []byte) error

type RequestMessage added in v0.6.0

type RequestMessage struct {
	Repository string // max:64
	Name       string // max:1024
	Offset     uint64
	Size       uint32
}

func (*RequestMessage) DecodeXDR added in v0.6.0

func (o *RequestMessage) DecodeXDR(r io.Reader) error

func (RequestMessage) EncodeXDR added in v0.6.0

func (o RequestMessage) EncodeXDR(w io.Writer) (int, error)

func (RequestMessage) MarshalXDR added in v0.6.0

func (o RequestMessage) MarshalXDR() []byte

func (*RequestMessage) UnmarshalXDR added in v0.6.0

func (o *RequestMessage) UnmarshalXDR(bs []byte) error

type Statistics

type Statistics struct {
	At            time.Time
	InBytesTotal  uint64
	OutBytesTotal uint64
}

Jump to

Keyboard shortcuts

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