Documentation
¶
Overview ¶
Package rpc contains ProtoBuf-generated types for the messages communicated between Akutan servers. It also contains some related types, such as FactSink and KGObject.
Index ¶
- type ChunkReadyCallback
- type FactSink
- type KGObject
- func ABool(v bool, unitID uint64) KGObject
- func AFloat64(fv float64, unitID uint64) KGObject
- func AInt64(v int64, unitID uint64) KGObject
- func AKID(kid uint64) KGObject
- func AString(s string, langID uint64) KGObject
- func ATimestamp(v time.Time, p logentry.TimestampPrecision, unitID uint64) KGObject
- func ATimestampY(year int, unitID uint64) KGObject
- func ATimestampYM(year int, month int, unitID uint64) KGObject
- func ATimestampYMD(year int, month int, day int, unitID uint64) KGObject
- func ATimestampYMDH(year, month, day, hour int, unitID uint64) KGObject
- func ATimestampYMDHM(year, month, day, hour, minute int, unitID uint64) KGObject
- func ATimestampYMDHMS(year, month, day, hour, minute, second int, unitID uint64) KGObject
- func ATimestampYMDHMSN(year, month, day, hour, minute, second, nsec int, unitID uint64) KGObject
- func KGObjectFromAPI(from api.KGObject) KGObject
- func KGObjectFromBytes(data []byte) (KGObject, error)
- func (o *KGObject) AsBytes() []byte
- func (o KGObject) AsString() string
- func (o KGObject) Equal(other KGObject) bool
- func (o KGObject) IsType(t KGObjectType) bool
- func (o KGObject) Key(b *strings.Builder)
- func (o KGObject) LangID() uint64
- func (o KGObject) Less(right KGObject) bool
- func (o *KGObject) Marshal() ([]byte, error)
- func (o *KGObject) MarshalTo(data []byte) (n int, err error)
- func (o *KGObject) Size() int
- func (o KGObject) String() string
- func (o KGObject) ToAPIObject() api.KGObject
- func (o KGObject) TypePrefix() []byte
- func (o KGObject) UnitID() uint64
- func (o *KGObject) Unmarshal(data []byte) error
- func (o KGObject) ValBool() bool
- func (o KGObject) ValFloat64() float64
- func (o KGObject) ValInt64() int64
- func (o KGObject) ValKID() uint64
- func (o KGObject) ValString() string
- func (o KGObject) ValTimestamp() logentry.KGTimestamp
- func (o KGObject) ValueType() KGObjectType
- func (o KGObject) WriteTo(buff *bytes.Buffer, opts WriteOpts)
- type KGObjectType
- type MockChunkStream
- type WriteOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChunkReadyCallback ¶
type ChunkReadyCallback func(*LookupChunk) error
ChunkReadyCallback will be called when the LookupSink has ready chunks to pass along This signature matches various grpc streaming endpoints
type FactSink ¶
type FactSink struct {
// contains filtered or unexported fields
}
FactSink accumulates facts and sends them to the destination in large chunks.
func NewFactSink ¶
func NewFactSink(readyCallback ChunkReadyCallback, flushAtSize int) *FactSink
NewFactSink constructs a new LookupSink, once 'flustAtSize' items have been accumulated the readyCallback function will be called with the new chunk
func (*FactSink) Flush ¶
Flush sends a chunk of facts to the destination, if needed. It returns nil on success, or an error if sending the chunk failed.
type KGObject ¶
type KGObject struct {
// contains filtered or unexported fields
}
KGObject represents a value of the Object field of a fact, this can be a KID i.e. another node in the graph, or it can be a typed literal value. String literals can also have a Language ID set (LangID) other literal types can have a Units ID set (UnitID). KGObject is safe to use as a key in a map. The zero value for KGObject maps to the KtNil ObjectType
func AFloat64 ¶
AFloat64 returns a new KGObject instance containing the supplied float and Units ID.
func AString ¶
AString returns a new KGObject instance containing the supplied string and language ID.
func ATimestamp ¶
ATimestamp returns a new KGObject instance containing a Timestamp for the supplied dateTime, precision and Units ID.
func ATimestampY ¶
ATimestampY returns a new KGObject instance containing a Timestamp for the specified year and Units ID.
func ATimestampYM ¶
ATimestampYM returns a new KGObject instance containing a Timestamp for the specified year, month and Units ID.
func ATimestampYMD ¶
ATimestampYMD returns a new KGObject instance containing a Timestamp for the specified year, month, day and Units ID.
func ATimestampYMDH ¶
ATimestampYMDH returns a new KGObject instance containing a Timestamp for the specified year, month, day, hour and Units ID.
func ATimestampYMDHM ¶
ATimestampYMDHM returns a new KGObject instance containing a Timestamp for the specified year, month, day, hour, minutes and Units ID.
func ATimestampYMDHMS ¶
ATimestampYMDHMS returns a new KGObject instance containing a Timestamp for the specified year, month, day, hour, minutes, seconds and Units ID.
func ATimestampYMDHMSN ¶
ATimestampYMDHMSN returns a new KGObject instance containing a Timestamp for the specified year, month, day, hour, minutes, seconds, nanoseonds, and Units ID.
func KGObjectFromAPI ¶
KGObjectFromAPI returns a new KGObject instance that is equivilent to the supplied API representation of a KGObject. The rpc.KGObject encapsulates a binary encoding of the KGObject
func KGObjectFromBytes ¶
KGObjectFromBytes constructs a new KGObject instance from the provided serialized state it may return an error if it doesn't contain a valid encoded KGObject state.
func (*KGObject) AsBytes ¶
AsBytes returns a serialized state of this KGObject. You can take these bytes and pass them to KGObjectFromBytes to re-hydrate a KGObject instance
func (KGObject) AsString ¶
AsString returns a serialized state of this KGObject as a non-printable string.
func (KGObject) IsType ¶
func (o KGObject) IsType(t KGObjectType) bool
IsType returns true if this KGObject contains the indicated type
func (KGObject) Key ¶
Key implements cmp.Key; it writes the identity key for the object to the given strings.Builder. This key has two properties. First, two KGObjects are equal if and only if their Key output is equal. Second, the Key output is human-readable. Note that the current String() method does not currently have the first property (is "2018" a timestamp or an int64?), and the binary encoding clearly doesn't have the second property.
func (KGObject) LangID ¶
LangID returns the Language ID if the contained type is KtString, otherwise it returns 0
func (KGObject) Less ¶
Less returns true if 'o' is lexicographically smaller than 'right' When 'o' & 'right' are of different types, the types are compared in a consistent order
func (*KGObject) Marshal ¶
Marshal will return the bytes required to later unmarshal an instance of this KGObject back into the same value. This never returns an error.
func (*KGObject) MarshalTo ¶
MarshalTo will copy a serialized version of this KGObject into the supplied 'data' byte slice. The number of bytes copied are returned, if the supplied slice is too small, it'll end up with just the prefix that fits. This never returns an error.
func (*KGObject) Size ¶
Size returns the number of bytes required to serialize an instance of this KGObject
func (KGObject) String ¶
String returns a human readable representation of the contained value to aid in debugging. TODO: this should match the format used in the query language?
func (KGObject) ToAPIObject ¶
ToAPIObject will take this KGObject and return an KGObject in the external API format
func (KGObject) TypePrefix ¶
TypePrefix returns a byte slice that contain a prefix of the encoding that contains the type. This will contain the type indicator, and for types that have units, will also contain the units ID.
func (KGObject) UnitID ¶
UnitID returns the Units ID for the contained types that have units (bool, int, float, timestamp) otherwise it returns 0
func (*KGObject) Unmarshal ¶
Unmarshal will update this KGObject with marshaled value in the supplied 'data' bytes.
func (KGObject) ValBool ¶
ValBool returns the contained bool value if the type is KtBool otherwise it returns false
func (KGObject) ValFloat64 ¶
ValFloat64 returns the contained Float64 value if the type is KtFloat64. otherwise it returns 0
func (KGObject) ValInt64 ¶
ValInt64 returns the contained Int64 value if the type is KtInt64 otherwise it returns 0
func (KGObject) ValKID ¶
ValKID returns the contained KID value if the type is KtKID otherwise it returns 0
func (KGObject) ValString ¶
ValString returns the contained string value if the type is KtString otherwise it returns "" Don't get this confused with String() which returns a human readable representation of the Object.
func (KGObject) ValTimestamp ¶
func (o KGObject) ValTimestamp() logentry.KGTimestamp
ValTimestamp returns the contained Timestamp if the type is KtTimestamp otherwise it returns an empty/zero value KGTimestamp
func (KGObject) ValueType ¶
func (o KGObject) ValueType() KGObjectType
ValueType returns the contained KGObject type.
type KGObjectType ¶
type KGObjectType uint8
KGObjectType is used to describethe contained type within an KGObject. Instances of KGObjectType are encoded into the serialization format and so you should not change the values for existing types.
const ( // KtNil indicates the KGObject has no type. KtNil KGObjectType = 0 // KtString indicates the KGObject contains an arbitrary unicode string. KtString KGObjectType = 1 // KtFloat64 indicates the KGObject contains an 8 byte double precision float. KtFloat64 KGObjectType = 2 // KtInt64 indicates the KGObject contains an 8 byte signed integer. KtInt64 KGObjectType = 3 // KtTimestamp indicates the KGObject contains a KGTimestamp, which consists // of a point in time and a precision indication that says which fields to // pay attention to. KtTimestamp KGObjectType = 4 // KtBool indicates the KGObject contains a boolean. KtBool KGObjectType = 5 // KtKID indicates the KGObject contains a KID (a Knowledge Graph ID), aka a node in the graph // rather than a literal value. KtKID KGObjectType = 6 )
type MockChunkStream ¶
type MockChunkStream struct {
// contains filtered or unexported fields
}
MockChunkStream is designed to be used as a LookupChunkReadyCallback to collect all chunks flushed out of the LookupSink into a set. This is for writing tests.
func (*MockChunkStream) ByOffset ¶
func (s *MockChunkStream) ByOffset() [][]Fact
ByOffset will return a slice of lists of facts, each index into the slice equals the offset that was set in the Fact, at each index, there is a list facts in the order they were recieved for that offset.
func (*MockChunkStream) Chunks ¶
func (s *MockChunkStream) Chunks() []*LookupChunk
Chunks returns the list of chunks accumulated, each LookupChunk was from a callback to Send
func (*MockChunkStream) Flatten ¶
func (s *MockChunkStream) Flatten() *LookupChunk
Flatten returns all the facts previously sent into one big chunk.
func (*MockChunkStream) Reset ¶
func (s *MockChunkStream) Reset()
Reset will discard all collected chunks and reset nextErr
func (*MockChunkStream) Send ¶
func (s *MockChunkStream) Send(chunk *LookupChunk) error
Send implements LookupChunkReadyCallback so that this can be a destination of a LookupSink
func (*MockChunkStream) SetNextError ¶
func (s *MockChunkStream) SetNextError(err error)
SetNextError will cause the next callback (and only the next callback) to Send to return an error