Documentation
¶
Overview ¶
Package zenoh provides the Zenoh client API in Go.
Index ¶
- Constants
- func RNameIntersect(rname1 string, rname2 string) bool
- func VleDecode(buf []byte) (int, []byte)
- func VleEncode(value int) []byte
- type DataHandler
- type DataInfo
- type Eval
- type Publisher
- type QueryDest
- type QueryDestKind
- type QueryHandler
- type RepliesSender
- type ReplyHandler
- type ReplyKind
- type ReplyValue
- type Resource
- type Storage
- type SubMode
- type SubModeKind
- type Subscriber
- type Timestamp
- type ZError
- type Zenoh
- func (z *Zenoh) Close() error
- func (z *Zenoh) DeclareEval(resource string, handler QueryHandler) (*Eval, error)
- func (z *Zenoh) DeclarePublisher(resource string) (*Publisher, error)
- func (z *Zenoh) DeclareStorage(resource string, dataHandler DataHandler, queryHandler QueryHandler) (*Storage, error)
- func (z *Zenoh) DeclareSubscriber(resource string, mode SubMode, dataHandler DataHandler) (*Subscriber, error)
- func (z *Zenoh) Info() map[int][]byte
- func (z *Zenoh) Query(resource string, predicate string, replyHandler ReplyHandler) error
- func (z *Zenoh) QueryWO(resource string, predicate string, replyHandler ReplyHandler, ...) error
- func (z *Zenoh) UndeclareEval(e *Eval) error
- func (z *Zenoh) UndeclarePublisher(p *Publisher) error
- func (z *Zenoh) UndeclareStorage(s *Storage) error
- func (z *Zenoh) UndeclareSubscriber(s *Subscriber) error
- func (z *Zenoh) WriteData(resource string, payload []byte) error
- func (z *Zenoh) WriteDataWO(resource string, payload []byte, encoding uint8, kind uint8) error
Constants ¶
const ZInfoPeerKey = C.Z_INFO_PEER_KEY
ZInfoPeerKey is the key for the peer value in the properties map returned by the Info() operation.
const ZInfoPeerPidKey = C.Z_INFO_PEER_PID_KEY
ZInfoPeerPidKey is the key for the peer's PID value in the properties map returned by the Info() operation.
const ZInfoPidKey = C.Z_INFO_PID_KEY
ZInfoPidKey is the key for the PID value in the properties map returned by the Info() operation.
const ZPasswdKey = C.Z_PASSWD_KEY
ZPasswdKey is the key for the (optional) user's password in the properties map passed to the Login() operation.
const ZUserKey = C.Z_USER_KEY
ZUserKey is the key for the (optional) user's name in the properties map passed to the Login() operation.
Variables ¶
This section is empty.
Functions ¶
func RNameIntersect ¶
RNameIntersect returns true if the resource name selector 'rname1' intersects with the resrouce name selector 'rname2'.
Types ¶
type DataHandler ¶
DataHandler will be called on reception of data matching the subscribed/stored resource.
type DataInfo ¶
type DataInfo = C.z_data_info_t
DataInfo is the information associated to a received data.
type Publisher ¶
Publisher is a Zenoh publisher
func (*Publisher) StreamCompactData ¶
StreamCompactData sends data in a 'compact_data' message for the resource selector published by publisher 'p'. 'payload' is the data to be sent.
func (*Publisher) StreamData ¶
StreamData sends data in a 'stream_data' message for the resource selector published by publisher 'p'. 'payload' is the data to be sent.
func (*Publisher) StreamDataWO ¶
StreamDataWO sends data in a 'stream_data' message for the resource selector published by publisher 'p'. 'payload' is the data to be sent. 'encoding' is a metadata information associated with the published data that represents the encoding of the published data. 'kind' is a metadata information associated with the published data that represents the kind of publication.
type QueryDest ¶
type QueryDest = C.z_query_dest_t
QueryDest is a Query destination
func NewQueryDest ¶
func NewQueryDest(kind QueryDestKind) QueryDest
NewQueryDest returns a QueryDest with the specified kind
func NewQueryDestWithNb ¶
func NewQueryDestWithNb(kind QueryDestKind, nb C.uint8_t) QueryDest
NewQueryDestWithNb returns a QueryDest with the specified kind and nb
type QueryDestKind ¶
QueryDestKind is the kind of a Query destination
const ( // ZBestMatch : the nearest complete storage/eval if there is one, all storages/evals if not. ZBestMatch QueryDestKind = iota // ZComplete : only complete storages/evals. ZComplete QueryDestKind = iota // ZAll : all storages/evals. ZAll QueryDestKind = iota // ZNone : no storages/evals. ZNone QueryDestKind = iota )
type QueryHandler ¶
type QueryHandler func(rname string, predicate string, sendReplies *RepliesSender)
QueryHandler will be called on reception of query matching the stored/evaluated resource. The QueryHandler must provide the data matching the resource selection 'rname' by calling the 'sendReplies' function of the 'RepliesSender'. The 'sendReplies' function MUST be called but accepts empty data array.
type RepliesSender ¶
type RepliesSender struct {
// contains filtered or unexported fields
}
RepliesSender is used in a storage's and eval's QueryHandler() implementation to send back replies to a query.
func (*RepliesSender) SendReplies ¶
func (rs *RepliesSender) SendReplies(replies []Resource)
SendReplies sends the replies to a query in a storage or eval. This operation should be called in the implementation of a QueryHandler
type ReplyHandler ¶
type ReplyHandler func(reply *ReplyValue)
ReplyHandler will be called on reception of replies to a query.
type ReplyKind ¶
ReplyKind is the kind of a ReplyValue
const ( // ZStorageData : a reply with data from a storage ZStorageData ReplyKind = iota // ZStorageFinal : a final reply from a storage (without data) ZStorageFinal ReplyKind = iota // ZEvalData : a reply with data from an eval ZEvalData ReplyKind = iota // ZEvalFinal : a final reply from an eval (without data) ZEvalFinal ReplyKind = iota // ZReplyFinal : the final reply (without data) ZReplyFinal ReplyKind = iota )
type ReplyValue ¶
type ReplyValue = C.z_reply_value_t
ReplyValue is a reply to a query
func (*ReplyValue) Data ¶
func (r *ReplyValue) Data() []byte
Data returns the data of this reply, if the Reply message kind is Z_STORAGE_DATA. Otherwise, it returns null
func (*ReplyValue) Info ¶
func (r *ReplyValue) Info() DataInfo
Info returns the DataInfo associated to this reply
func (*ReplyValue) RName ¶
func (r *ReplyValue) RName() string
RName returns the resource name of this reply
func (*ReplyValue) SrcID ¶
func (r *ReplyValue) SrcID() []byte
SrcID returns the unique id of the storage or eval that sent this reply
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage is a Zenoh storage
type SubMode ¶
type SubMode = C.z_sub_mode_t
SubMode is a Subscriber mode
func NewSubMode ¶
func NewSubMode(kind SubModeKind) SubMode
NewSubMode returns a SubMode with the specified kind
func NewSubModeWithTime ¶
NewSubModeWithTime returns a SubMode with the specified kind and temporal properties
type SubModeKind ¶
SubModeKind is the kind of a Subscriber mode
const ( // ZPushMode : push mode for subscriber ZPushMode SubModeKind = iota + 1 // ZPullMode : pull mode for subscriber ZPullMode SubModeKind = iota + 1 // ZPeriodicPushMode : periodic push mode for subscriber ZPeriodicPushMode SubModeKind = iota + 1 // ZPeriodicPullMode : periodic pull mode for subscriber ZPeriodicPullMode SubModeKind = iota + 1 )
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber is a Zenoh subscriber
func (*Subscriber) Pull ¶
func (s *Subscriber) Pull() error
Pull data for the `ZPullMode` or `ZPeriodicPullMode` subscription 's'. The pulled data will be provided by calling the 'dataHandler' function provided to the `DeclareSubscriber` function.
type Timestamp ¶
type Timestamp = C.z_timestamp_t
Timestamp is a Zenoh timestamp
func (*Timestamp) Before ¶
Before reports whether the Timestamp ts was created before ots. This function can be used for sorting.
type ZError ¶
type ZError struct {
// contains filtered or unexported fields
}
ZError reports an error that occurred in the zenoh-c library
type Zenoh ¶
Zenoh API
func ZOpen ¶
ZOpen opens a zenoh session. 'locator' is a pointer to a string representing the network endpoint to which establish the session. A typical locator looks like this : “tcp/127.0.0.1:7447“. If 'locator' is "nil", 'open' will scout and try to establish the session automatically. 'properties' is a map of properties that will be used to establish and configure the zenoh session. 'properties' will typically contain the username and password informations needed to establish the zenoh session with a secured infrastructure. It can be set to "nil". Return a handle to the zenoh session.
func (*Zenoh) DeclareEval ¶
func (z *Zenoh) DeclareEval(resource string, handler QueryHandler) (*Eval, error)
DeclareEval declares an eval able to provide data matching the provided resource selector 'resource'. 'resource' is the resource selection to evaluate. 'handler' is the callback function that will be called each time a query for data matching the evaluated 'resource' selection is received. The 'handler' function MUST call the provided 'sendReplies' function with the resulting data. 'sendReplies'can be called with an empty array. Return a zenoh eval.
func (*Zenoh) DeclarePublisher ¶
DeclarePublisher declares a publication for resource selection 'resource'. 'resource' is the resource selection to publish. Return a zenoh publisher.
func (*Zenoh) DeclareStorage ¶
func (z *Zenoh) DeclareStorage(resource string, dataHandler DataHandler, queryHandler QueryHandler) (*Storage, error)
DeclareStorage declares a storage for all data matching the provided resource selector 'resource'. 'resource' is the resource selection to store. 'dataHandler' is the callback function that will be called each time a data matching the stored 'resource' selection is received. 'queryHandler' is the callback function that will be called each time a query for data matching the stored 'resource' selection is received. The 'queryHandler' function MUST call the provided 'sendReplies' function with the resulting data. 'sendReplies' can be called with an empty array. Return a zenoh storage.
func (*Zenoh) DeclareSubscriber ¶
func (z *Zenoh) DeclareSubscriber(resource string, mode SubMode, dataHandler DataHandler) (*Subscriber, error)
DeclareSubscriber declares a subscription for all published data matching the provided resource selector 'resource'. 'resource' is the resource selection to subscribe to. 'mode' is the subscription mode. 'dataHandler' is the callback function that will be called each time a data matching the subscribed 'resource' selectoin is received. Return a zenoh subscriber.
func (*Zenoh) Info ¶
Info returns a map of properties containing various informations about the established zenoh session 'z'.
func (*Zenoh) Query ¶
func (z *Zenoh) Query(resource string, predicate string, replyHandler ReplyHandler) error
Query sends a query message for data matching the resource selector 'resource'. 'resource' is the resource selection to query. 'predicate' is a string that will be propagated to the storages and evals that should provide the queried data. It may allow them to filter, transform and/or compute the queried data. 'replyHandler' is the callback function that will be called on reception of the replies of the query.
func (*Zenoh) QueryWO ¶
func (z *Zenoh) QueryWO(resource string, predicate string, replyHandler ReplyHandler, destStorages QueryDest, destEvals QueryDest) error
QueryWO sends a query message data matching resource selector 'resource'. 'resource' is the resource selection to query. 'predicate' is a string that will be propagated to the storages and evals that should provide the queried data. It may allow them to filter, transform and/or compute the queried data. 'replyHandler' is the callback function that will be called on reception of the replies of the query. 'destStorages' indicates which matching storages should be destination of the query. 'destEvals' indicates which matching evals should be destination of the query.
func (*Zenoh) UndeclareEval ¶
UndeclareEval undeclares the eval 'e'.
func (*Zenoh) UndeclarePublisher ¶
UndeclarePublisher undeclares the publication 'p'.
func (*Zenoh) UndeclareStorage ¶
UndeclareStorage undeclares the storage 's'.
func (*Zenoh) UndeclareSubscriber ¶
func (z *Zenoh) UndeclareSubscriber(s *Subscriber) error
UndeclareSubscriber undeclares the subscription 's'.
func (*Zenoh) WriteData ¶
WriteData sends data in a 'write_data' message for the resource selector 'resource'. 'resource' is the resource name selector of the data to be sent. 'payload' is the data to be sent.
func (*Zenoh) WriteDataWO ¶
WriteDataWO sends data in a 'write_data' message for the resource selector 'resource'. 'resource' is the resource name selector of the data to be sent. 'payload' is the data to be sent. 'encoding' is a metadata information associated with the published data that represents the encoding of the published data. 'kind' is a metadata information associated with the published data that represents the kind of publication.