zenoh

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 29, 2020 License: Apache-2.0 Imports: 11 Imported by: 1

README

Documentation Status GoReport Status

zenoh-go

Go client for zenoh.

Documentation

Overview

Package zenoh provides the Zenoh client API in Go.

Index

Constants

View Source
const ZInfoPeerKey = C.Z_INFO_PEER_KEY

ZInfoPeerKey is the key for the peer value in the properties map returned by the Info() operation.

View Source
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.

View Source
const ZInfoPidKey = C.Z_INFO_PID_KEY

ZInfoPidKey is the key for the PID value in the properties map returned by the Info() operation.

View Source
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.

View Source
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

func RNameIntersect(rname1 string, rname2 string) bool

RNameIntersect returns true if the resource name selector 'rname1' intersects with the resrouce name selector 'rname2'.

func VleDecode

func VleDecode(buf []byte) (int, []byte)

VleDecode returns the int value decoded from a VLE encoded in a []byte

func VleEncode

func VleEncode(value int) []byte

VleEncode returns the value as a VLE encoded in a []byte

Types

type DataHandler

type DataHandler func(rid string, data []byte, info *DataInfo)

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.

func (*DataInfo) Encoding

func (info *DataInfo) Encoding() uint8

Encoding returns the encoding from a DataInfo

func (*DataInfo) Flags

func (info *DataInfo) Flags() uint

Flags returns the flags from a DataInfo

func (*DataInfo) Kind

func (info *DataInfo) Kind() uint8

Kind returns the kind from a DataInfo

func (*DataInfo) Tstamp

func (info *DataInfo) Tstamp() Timestamp

Tstamp returns the timestamp from a DataInfo

type Eval

type Eval struct {
	// contains filtered or unexported fields
}

Eval is a Zenoh eval

type Publisher

type Publisher = C.z_pub_t

Publisher is a Zenoh publisher

func (*Publisher) StreamCompactData

func (p *Publisher) StreamCompactData(payload []byte) error

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

func (p *Publisher) StreamData(payload []byte) error

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

func (p *Publisher) StreamDataWO(payload []byte, encoding uint8, kind uint8) error

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

type QueryDestKind = C.uint8_t

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

type ReplyKind = C.char

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) Kind

func (r *ReplyValue) Kind() ReplyKind

Kind returns the Reply message kind

func (*ReplyValue) RName

func (r *ReplyValue) RName() string

RName returns the resource name of this reply

func (*ReplyValue) RSN

func (r *ReplyValue) RSN() uint64

RSN returns the request sequence number

func (*ReplyValue) SrcID

func (r *ReplyValue) SrcID() []byte

SrcID returns the unique id of the storage or eval that sent this reply

type Resource

type Resource struct {
	RName    string
	Data     []byte
	Encoding uint8
	Kind     uint8
}

Resource is a Zenoh resource with a name and a value (data).

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

func NewSubModeWithTime(kind SubModeKind, origin C.ulong, period C.ulong, duration C.ulong) SubMode

NewSubModeWithTime returns a SubMode with the specified kind and temporal properties

type SubModeKind

type SubModeKind = C.uint8_t

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

func (ts *Timestamp) Before(ots *Timestamp) bool

Before reports whether the Timestamp ts was created before ots. This function can be used for sorting.

func (*Timestamp) ClockID

func (ts *Timestamp) ClockID() [16]byte

ClockID returns the clock id of a Timestamp

func (*Timestamp) GoTime

func (ts *Timestamp) GoTime() time.Time

GoTime returns the time of a Timestamp as a Go time.Time

func (*Timestamp) String

func (ts *Timestamp) String() string

String returns the Timestamp as a string

func (*Timestamp) Time

func (ts *Timestamp) Time() uint64

Time returns the time of a Timestamp

type ZError

type ZError struct {
	// contains filtered or unexported fields
}

ZError reports an error that occurred in the zenoh-c library

func (*ZError) Error

func (e *ZError) Error() string

Error returns the message associated to a ZError

type Zenoh

type Zenoh = C.z_zenoh_t

Zenoh API

func ZOpen

func ZOpen(locator *string, properties map[int][]byte) (*Zenoh, error)

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) Close

func (z *Zenoh) Close() error

Close the zenoh session 'z'.

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

func (z *Zenoh) DeclarePublisher(resource string) (*Publisher, error)

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

func (z *Zenoh) Info() map[int][]byte

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

func (z *Zenoh) UndeclareEval(e *Eval) error

UndeclareEval undeclares the eval 'e'.

func (*Zenoh) UndeclarePublisher

func (z *Zenoh) UndeclarePublisher(p *Publisher) error

UndeclarePublisher undeclares the publication 'p'.

func (*Zenoh) UndeclareStorage

func (z *Zenoh) UndeclareStorage(s *Storage) error

UndeclareStorage undeclares the storage 's'.

func (*Zenoh) UndeclareSubscriber

func (z *Zenoh) UndeclareSubscriber(s *Subscriber) error

UndeclareSubscriber undeclares the subscription 's'.

func (*Zenoh) WriteData

func (z *Zenoh) WriteData(resource string, payload []byte) error

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

func (z *Zenoh) WriteDataWO(resource string, payload []byte, encoding uint8, kind uint8) error

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.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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