Documentation
¶
Index ¶
- Constants
- func FmtMetaKVs(values map[string]string) []byte
- func MarshalPacket(p Packet) ([]byte, error)
- func ParseMetaKVs(data []byte) map[string]string
- type AdmissionPolicy
- type Client
- func (c *Client) CreateObject(data, metadata []byte) (*Object, error)
- func (c *Client) GetObjectSnapshot(id ObjectID, includeData bool) (ObjectSnapshot, bool)
- func (c *Client) PinObject(id ObjectID) bool
- func (c *Client) Start(ctx context.Context)
- func (c *Client) Stop()
- func (c *Client) SubscribeObject(id ObjectID, buf int) (<-chan ObjectEvent, func())
- func (c *Client) SubscribeObjects(buf int) (<-chan *Object, func())
- func (c *Client) UnpinObject(id ObjectID) bool
- type ClientOpts
- type FragPacket
- type FragmentRef
- type HavePacket
- type Object
- type ObjectEvent
- type ObjectEventKind
- type ObjectHash
- type ObjectID
- type ObjectSnapshot
- type Packet
- type WantPacket
Constants ¶
View Source
const ( OptimisticBurstDisabled uint16 = 0 OptimisticBurstAll uint16 = ^uint16(0) )
View Source
const ( PacketTypeHave uint8 = iota PacketTypeWant PacketTypeFrag )
Variables ¶
This section is empty.
Functions ¶
func FmtMetaKVs ¶
func MarshalPacket ¶
func ParseMetaKVs ¶
Types ¶
type AdmissionPolicy ¶
type AdmissionPolicy func(*HavePacket) bool
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClientWithOpts ¶
func NewClientWithOpts(ifaceName string, opts ClientOpts) (*Client, error)
func (*Client) GetObjectSnapshot ¶
func (c *Client) GetObjectSnapshot(id ObjectID, includeData bool) (ObjectSnapshot, bool)
func (*Client) SubscribeObject ¶
func (c *Client) SubscribeObject(id ObjectID, buf int) (<-chan ObjectEvent, func())
func (*Client) SubscribeObjects ¶
func (*Client) UnpinObject ¶
type ClientOpts ¶
type ClientOpts struct {
ObjectCapacity int
SweepInterval time.Duration
ReannounceInterval time.Duration
DefaultReceivedIncompleteTTL time.Duration
DefaultReceivedCompleteTTL time.Duration
DefaultCreatedCompleteTTL time.Duration
WantRetryDelay time.Duration
WantMaxRetries int
QueueHaveCapacity int
QueueWantCapacity int
QueueOwnedCapacity int
QueueReplicaCapacity int
SeenFragCapacity int
SeenFragTTL time.Duration
ReplicaDelay time.Duration
ReplicaJitter time.Duration
OptimisticBurstMaxSize uint64
OptimisticBurstFrags uint16
AdmissionPolicy AdmissionPolicy
AutoPinOwned bool
AutoPinReceived bool
Logger *log.Logger
}
func DefaultClientOpts ¶
func DefaultClientOpts() ClientOpts
type FragPacket ¶
type FragPacket struct {
ObjectID ObjectID // half a sha256 hash
FragIndex uint16 // index of the fragment
Payload []byte // arbitrary payload
// not marshaled
SourceMAC net.HardwareAddr
}
func (*FragPacket) MarshalBinary ¶
func (p *FragPacket) MarshalBinary() ([]byte, error)
func (*FragPacket) Source ¶
func (p *FragPacket) Source() net.HardwareAddr
func (*FragPacket) UnmarshalBinary ¶
func (p *FragPacket) UnmarshalBinary(data []byte) error
type FragmentRef ¶
type HavePacket ¶
type HavePacket struct {
ObjectID ObjectID // half a sha256 hash
ObjectSize uint64 // it would be very funny to use the full extent of this
ObjectHash ObjectHash // sha256 hash of the entire object
FragCount uint16 // number of fragments in the object
Metadata []byte // arbitrary metadata idk what this will look like, can't be fragmented...
// not marshaled
SourceMAC net.HardwareAddr
}
func (*HavePacket) MarshalBinary ¶
func (p *HavePacket) MarshalBinary() ([]byte, error)
func (*HavePacket) Source ¶
func (p *HavePacket) Source() net.HardwareAddr
func (*HavePacket) UnmarshalBinary ¶
func (p *HavePacket) UnmarshalBinary(data []byte) error
type Object ¶
type Object struct {
ID ObjectID
Size uint64
Hash ObjectHash
FragCount uint16
Metadata []byte
Created time.Time
CompletedAt time.Time
Expires time.Time
LastHave time.Time
LastRetry time.Time
NextWant time.Time
Source net.HardwareAddr
Retries int
Owned bool
Pinned bool
Complete bool
Fragments map[uint16][]byte
Data []byte
}
func (*Object) HavePacket ¶
func (o *Object) HavePacket() *HavePacket
func (*Object) Snapshot ¶
func (o *Object) Snapshot(includeData bool) ObjectSnapshot
type ObjectEvent ¶
type ObjectEvent struct {
Kind ObjectEventKind
Object ObjectSnapshot
}
type ObjectEventKind ¶
type ObjectEventKind string
const ( ObjectEventDiscovered ObjectEventKind = "discovered" ObjectEventProgress ObjectEventKind = "progress" ObjectEventComplete ObjectEventKind = "complete" )
type ObjectHash ¶
type ObjectHash [32]byte
func ObjectHashBytes ¶
func ObjectHashBytes(data []byte) ObjectHash
func (ObjectHash) String ¶
func (h ObjectHash) String() string
type ObjectID ¶
type ObjectID [16]byte
func ObjectIDFromHash ¶
func ObjectIDFromHash(hash ObjectHash) ObjectID
func ParseObjectID ¶
type ObjectSnapshot ¶
type ObjectSnapshot struct {
ID ObjectID
Size uint64
Hash ObjectHash
FragCount uint16
Metadata []byte
Created time.Time
CompletedAt time.Time
Expires time.Time
LastHave time.Time
LastRetry time.Time
NextWant time.Time
Source net.HardwareAddr
Retries int
Owned bool
Pinned bool
Complete bool
ReceivedFrags uint16
ReceivedBytes uint64
Data []byte
}
type Packet ¶
type Packet interface {
MarshalBinary() ([]byte, error)
Source() net.HardwareAddr
}
func UnmarshalPacket ¶
type WantPacket ¶
type WantPacket struct {
ObjectID ObjectID // half a sha256 hash
FragCount uint16 // number of fragments wanted
Frags []uint16 // list of fragment indicies wanted
// not marshaled
SourceMAC net.HardwareAddr
}
func (*WantPacket) MarshalBinary ¶
func (p *WantPacket) MarshalBinary() ([]byte, error)
func (*WantPacket) Source ¶
func (p *WantPacket) Source() net.HardwareAddr
func (*WantPacket) UnmarshalBinary ¶
func (p *WantPacket) UnmarshalBinary(data []byte) error
Click to show internal directories.
Click to hide internal directories.