Documentation ¶
Overview ¶
Package dnode implements a dnode scrubber. See the following URL for details: https://github.com/substack/dnode-protocol/blob/master/doc/protocol.markdown
Index ¶
- func ParseCallbacks(msg *Message, sender func(id uint64, args []interface{}) error) error
- type ArgumentError
- type CallbackNotFoundError
- type CallbackSpec
- type Function
- type Message
- type MethodNotFoundError
- type Partial
- func (p *Partial) Bool() (b bool, err error)
- func (p *Partial) Float64() (f float64, err error)
- func (p *Partial) Function() (f Function, err error)
- func (p *Partial) Map() (m map[string]*Partial, err error)
- func (p *Partial) MarshalJSON() ([]byte, error)
- func (p *Partial) MustBool() bool
- func (p *Partial) MustFloat64() float64
- func (p *Partial) MustFunction() Function
- func (p *Partial) MustMap() map[string]*Partial
- func (p *Partial) MustSlice() []*Partial
- func (p *Partial) MustSliceOfLength(length int) []*Partial
- func (p *Partial) MustString() string
- func (p *Partial) MustUnmarshal(v interface{})
- func (p *Partial) One() *Partial
- func (p *Partial) Slice() (a []*Partial, err error)
- func (p *Partial) SliceOfLength(length int) (a []*Partial, err error)
- func (p *Partial) String() (s string, err error)
- func (p *Partial) Unmarshal(v interface{}) error
- func (p *Partial) UnmarshalJSON(data []byte) error
- type Path
- type Scrubber
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ArgumentError ¶
type ArgumentError struct {
// contains filtered or unexported fields
}
ArgumentError is returned when received message contains invalid arguments.
func (ArgumentError) Error ¶
func (e ArgumentError) Error() string
type CallbackNotFoundError ¶
CallbackNotFoundError is returned when there is no registered callback for received message.
func (CallbackNotFoundError) Error ¶
func (e CallbackNotFoundError) Error() string
type CallbackSpec ¶
type CallbackSpec struct { // Path represents the callback's path in the arguments structure. Path Path Function Function }
CallbackSpec is a structure encapsulating a Function and it's Path. It is the type of the values in callbacks map.
type Function ¶
type Function struct {
Caller caller
}
Function is the type for sending and receiving functions in dnode messages.
func (Function) IsValid ¶
IsValid returns true if f represents a Function. It returns false if f is the zero Value.
func (Function) MarshalJSON ¶
func (*Function) UnmarshalJSON ¶
type Message ¶
type Message struct { // Method can be an integer or string. Method interface{} `json:"method"` // Array of arguments Arguments *Partial `json:"arguments"` // Integer map of callback paths in arguments Callbacks map[string]Path `json:"callbacks"` }
Message is the JSON object to call a method at the other side.
type MethodNotFoundError ¶
MethodNotFoundError is returned when there is no registered handler for received method.
func (MethodNotFoundError) Error ¶
func (e MethodNotFoundError) Error() string
type Partial ¶
type Partial struct { Raw []byte CallbackSpecs []CallbackSpec }
Partial is the type of "arguments" field in dnode.Message.
func (*Partial) MarshalJSON ¶
MarshalJSON returns the raw bytes of the Partial.
func (*Partial) MustFloat64 ¶
func (*Partial) MustFunction ¶
func (*Partial) MustSliceOfLength ¶
func (*Partial) MustString ¶
func (*Partial) MustUnmarshal ¶
func (p *Partial) MustUnmarshal(v interface{})
func (*Partial) SliceOfLength ¶
SliceOfLength is a helper method to unmarshal a JSON Array with specified length.
func (*Partial) Unmarshal ¶
Unmarshal unmarshals the raw data (p.Raw) into v and prepares callbacks. v must be a struct that is the type of expected arguments.
func (*Partial) UnmarshalJSON ¶
UnmarshalJSON puts the data into Partial.Raw.
type Path ¶
type Path []interface{}
Path represents a callback function's path in the arguments structure. Contains mixture of string and integer values.
type Scrubber ¶
func (*Scrubber) GetCallback ¶
func (*Scrubber) RemoveCallback ¶
RemoveCallback removes the callback with id from callbacks. Can be used to remove unused callbacks to free memory.