Documentation ¶
Index ¶
- Constants
- Variables
- func AdvertiseServer(ctx *context.T, d discovery.T, server rpc.Server, suffix string, ...) (<-chan struct{}, error)
- func DecodeTimestamp(data []byte) (int64, error)
- func DecodeWireCiphertext(data []byte) (*bcrypter.WireCiphertext, error)
- func EncodeTimestamp(ts int64) []byte
- func EncodeWireCiphertext(wctext *bcrypter.WireCiphertext) []byte
- func NewErrAdvertisementNotFound(ctx *context.T, id discovery.AdId) error
- func NewErrAlreadyBeingAdvertised(ctx *context.T, id discovery.AdId) error
- func NewErrBadAdvertisement(ctx *context.T, err error) error
- func NewErrBadQuery(ctx *context.T, err error) error
- func NewErrDiscoveryClosed(ctx *context.T) error
- func NewErrNoDiscoveryPlugin(ctx *context.T) error
- func NewErrTooManyPlugins(ctx *context.T, actual int32, limit int32) error
- func NewUpdate(adinfo *AdInfo) discovery.Update
- func PackAddresses(addrs []string) []byte
- func PackEncryptionKeys(algo EncryptionAlgorithm, keys []EncryptionKey) []byte
- func UnpackAddresses(data []byte) ([]string, error)
- func UnpackEncryptionKeys(data []byte) (EncryptionAlgorithm, []EncryptionKey, error)
- type AdHash
- type AdInfo
- type AdStatus
- type Barrier
- type DirectoryClientMethods
- type DirectoryClientStub
- type DirectoryServerMethods
- type DirectoryServerStub
- type DirectoryServerStubMethods
- type EncodingBuffer
- func (e *EncodingBuffer) Bytes() []byte
- func (e *EncodingBuffer) Len() int
- func (e *EncodingBuffer) Next(n int) []byte
- func (e *EncodingBuffer) Read(p []byte) error
- func (e *EncodingBuffer) ReadBytes() ([]byte, error)
- func (e *EncodingBuffer) ReadInt() (int, error)
- func (e *EncodingBuffer) ReadString() (string, error)
- func (e *EncodingBuffer) Write(p []byte)
- func (e *EncodingBuffer) WriteBytes(p []byte)
- func (e *EncodingBuffer) WriteInt(x int)
- func (e *EncodingBuffer) WriteString(s string)
- type EncryptionAlgorithm
- type EncryptionKey
- type Factory
- type Matcher
- type Plugin
- type Trigger
- type Uuid
Constants ¶
const AdNotReady = AdStatus(1) // Not all information is available for querying against it
const AdPartiallyReady = AdStatus(2) // All information except attachments is available
const AdReady = AdStatus(0) // All information is available
const IbeEncryption = EncryptionAlgorithm(2)
const NoEncryption = EncryptionAlgorithm(0)
const TestEncryption = EncryptionAlgorithm(1)
Variables ¶
var ( ErrAdvertisementNotFound = verror.Register("v.io/x/ref/lib/discovery.AdvertisementNotFound", verror.NoRetry, "{1:}{2:} advertisement not found: {3}") ErrAlreadyBeingAdvertised = verror.Register("v.io/x/ref/lib/discovery.AlreadyBeingAdvertised", verror.NoRetry, "{1:}{2:} already being advertised: {3}") ErrBadAdvertisement = verror.Register("v.io/x/ref/lib/discovery.BadAdvertisement", verror.NoRetry, "{1:}{2:} invalid advertisement: {3}") ErrBadQuery = verror.Register("v.io/x/ref/lib/discovery.BadQuery", verror.NoRetry, "{1:}{2:} invalid query: {3}") ErrDiscoveryClosed = verror.Register("v.io/x/ref/lib/discovery.DiscoveryClosed", verror.NoRetry, "{1:}{2:} discovery closed") ErrNoDiscoveryPlugin = verror.Register("v.io/x/ref/lib/discovery.NoDiscoveryPlugin", verror.NoRetry, "{1:}{2:} no discovery plugin") ErrTooManyPlugins = verror.Register("v.io/x/ref/lib/discovery.TooManyPlugins", verror.NoRetry, "{1:}{2:} too many plugins ({3}), support at most {4}") )
var DirectoryDesc rpc.InterfaceDesc = descDirectory
DirectoryDesc describes the Directory interface.
Functions ¶
func AdvertiseServer ¶
func AdvertiseServer(ctx *context.T, d discovery.T, server rpc.Server, suffix string, ad *discovery.Advertisement, visibility []security.BlessingPattern) (<-chan struct{}, error)
AdvertiseServer advertises the server with the given advertisement. It uses the server's endpoints and the given suffix as the advertisement addresses, and the addresses will be updated automatically when the underlying network are changed.
The advertisement should not be changed while it is being advertised.
Advertising will continue until the context is canceled or exceeds its deadline and the returned channel will be closed when it stops.
If a discovery instance is not provided, this will create a new one.
func DecodeTimestamp ¶
DecodeTimestamp decodes the timestamp from a 8-byte byte slice.
func DecodeWireCiphertext ¶
func DecodeWireCiphertext(data []byte) (*bcrypter.WireCiphertext, error)
DecodeCiphertext decodes the cipher text from a byte slice.
func EncodeTimestamp ¶
EncodeTimestamp encodes the timestamp into a 8-byte byte slice.
func EncodeWireCiphertext ¶
func EncodeWireCiphertext(wctext *bcrypter.WireCiphertext) []byte
EncodeCiphertext encodes the cipher text into a byte slice.
func NewErrAdvertisementNotFound ¶
NewErrAdvertisementNotFound returns an error with the ErrAdvertisementNotFound ID.
func NewErrAlreadyBeingAdvertised ¶
NewErrAlreadyBeingAdvertised returns an error with the ErrAlreadyBeingAdvertised ID.
func NewErrBadAdvertisement ¶
NewErrBadAdvertisement returns an error with the ErrBadAdvertisement ID.
func NewErrBadQuery ¶
NewErrBadQuery returns an error with the ErrBadQuery ID.
func NewErrDiscoveryClosed ¶
NewErrDiscoveryClosed returns an error with the ErrDiscoveryClosed ID.
func NewErrNoDiscoveryPlugin ¶
NewErrNoDiscoveryPlugin returns an error with the ErrNoDiscoveryPlugin ID.
func NewErrTooManyPlugins ¶
NewErrTooManyPlugins returns an error with the ErrTooManyPlugins ID.
func PackAddresses ¶
PackAddresses packs addresses into a byte slice.
func PackEncryptionKeys ¶
func PackEncryptionKeys(algo EncryptionAlgorithm, keys []EncryptionKey) []byte
PackEncryptionKeys packs encryption algorithm and keys into a byte slice.
func UnpackAddresses ¶
UnpackAddresses unpacks addresses from a byte slice.
func UnpackEncryptionKeys ¶
func UnpackEncryptionKeys(data []byte) (EncryptionAlgorithm, []EncryptionKey, error)
UnpackEncryptionKeys unpacks encryption algorithm and keys from a byte slice.
Types ¶
type AdHash ¶
type AdHash [8]byte
An AdHash is a hash of an advertisement.
func (AdHash) VDLReflect ¶
type AdInfo ¶
type AdInfo struct { Ad discovery.Advertisement // Type of encryption applied to the advertisement so that it can // only be decoded by authorized principals. EncryptionAlgorithm EncryptionAlgorithm // If the advertisement is encrypted, then the data required to // decrypt it. The format of this data is a function of the algorithm. EncryptionKeys []EncryptionKey // Hash of the current advertisement. This does not include the fields below. Hash AdHash // Unix time in nanoseconds at which the advertisement was created. TimestampNs int64 // The addresses (vanadium object names) that the advertisement directory service // is served on. See directory.vdl. DirAddrs []string // Status of the current advertisement. Valid for scanned advertisements. Status AdStatus // TODO(jhahn): Add proximity. // TODO(jhahn): Use proximity for Lost. Lost bool }
AdInfo represents advertisement information for discovery.
func (AdInfo) VDLReflect ¶
type Barrier ¶
type Barrier struct {
// contains filtered or unexported fields
}
A Barrier is a simple incremental barrier that runs a done closure after all closures returned by Add() have been invoked. The done closure will run only once and run in a separate goroutine.
func NewBarrier ¶
func NewBarrier(done func()) *Barrier
type DirectoryClientMethods ¶
type DirectoryClientMethods interface { // Lookup returns the advertisement of the given service instance. // // The returned advertisement may not include all attachments. Lookup(_ *context.T, id discovery.AdId, _ ...rpc.CallOpt) (AdInfo, error) // GetAttachment returns the named attachment. Accessing non-existent attachment // is not an error - nil data is returned if not found. // // TODO(jhahn): Consider to return an error if not found. GetAttachment(_ *context.T, id discovery.AdId, name string, _ ...rpc.CallOpt) ([]byte, error) }
DirectoryClientMethods is the client interface containing Directory methods.
Directory is the interface for advertisement directory service.
type DirectoryClientStub ¶
type DirectoryClientStub interface { DirectoryClientMethods rpc.UniversalServiceMethods }
DirectoryClientStub adds universal methods to DirectoryClientMethods.
func DirectoryClient ¶
func DirectoryClient(name string) DirectoryClientStub
DirectoryClient returns a client stub for Directory.
type DirectoryServerMethods ¶
type DirectoryServerMethods interface { // Lookup returns the advertisement of the given service instance. // // The returned advertisement may not include all attachments. Lookup(_ *context.T, _ rpc.ServerCall, id discovery.AdId) (AdInfo, error) // GetAttachment returns the named attachment. Accessing non-existent attachment // is not an error - nil data is returned if not found. // // TODO(jhahn): Consider to return an error if not found. GetAttachment(_ *context.T, _ rpc.ServerCall, id discovery.AdId, name string) ([]byte, error) }
DirectoryServerMethods is the interface a server writer implements for Directory.
Directory is the interface for advertisement directory service.
type DirectoryServerStub ¶
type DirectoryServerStub interface { DirectoryServerStubMethods // Describe the Directory interfaces. Describe__() []rpc.InterfaceDesc }
DirectoryServerStub adds universal methods to DirectoryServerStubMethods.
func DirectoryServer ¶
func DirectoryServer(impl DirectoryServerMethods) DirectoryServerStub
DirectoryServer returns a server stub for Directory. It converts an implementation of DirectoryServerMethods into an object that may be used by rpc.Server.
type DirectoryServerStubMethods ¶
type DirectoryServerStubMethods DirectoryServerMethods
DirectoryServerStubMethods is the server interface containing Directory methods, as expected by rpc.Server. There is no difference between this interface and DirectoryServerMethods since there are no streaming methods.
type EncodingBuffer ¶
type EncodingBuffer struct {
// contains filtered or unexported fields
}
EncodingBuffer is used to encode and decode advertisements.
func NewEncodingBuffer ¶
func NewEncodingBuffer(data []byte) *EncodingBuffer
NewEncodingBuffer returns a new encoding buffer.
func (*EncodingBuffer) Bytes ¶
func (e *EncodingBuffer) Bytes() []byte
Bytes returns a byte slice holding the unread portion of the buffer.
func (*EncodingBuffer) Len ¶
func (e *EncodingBuffer) Len() int
Len returns the number of bytes of the unread portion of the buffer.
func (*EncodingBuffer) Next ¶
func (e *EncodingBuffer) Next(n int) []byte
Next returns a slice containing the next n bytes from the buffer. If there are fewer than n bytes in the buffer, it returns the entire buffer.
func (*EncodingBuffer) Read ¶
func (e *EncodingBuffer) Read(p []byte) error
Read reads the next len(p) bytes from the buffer. If the buffer has no enough data, io.EOF is returned.
func (*EncodingBuffer) ReadBytes ¶
func (e *EncodingBuffer) ReadBytes() ([]byte, error)
ReadBytes reads a byte slice with its length from the buffer.
func (*EncodingBuffer) ReadInt ¶
func (e *EncodingBuffer) ReadInt() (int, error)
ReadInt reads an integer from the buffer.
func (*EncodingBuffer) ReadString ¶
func (e *EncodingBuffer) ReadString() (string, error)
ReadString reads a string from the buffer.
func (*EncodingBuffer) Write ¶
func (e *EncodingBuffer) Write(p []byte)
Write appends a byte slice to the buffer.
func (*EncodingBuffer) WriteBytes ¶
func (e *EncodingBuffer) WriteBytes(p []byte)
WriteBytes appends a byte slice to the buffer with its length.
func (*EncodingBuffer) WriteInt ¶
func (e *EncodingBuffer) WriteInt(x int)
WriteInt appends an integer to the buffer.
func (*EncodingBuffer) WriteString ¶
func (e *EncodingBuffer) WriteString(s string)
WriteString appends a string to the buffer.
type EncryptionAlgorithm ¶
type EncryptionAlgorithm int32
func (EncryptionAlgorithm) VDLIsZero ¶
func (x EncryptionAlgorithm) VDLIsZero() bool
func (EncryptionAlgorithm) VDLReflect ¶
func (EncryptionAlgorithm) VDLReflect(struct { Name string `vdl:"v.io/x/ref/lib/discovery.EncryptionAlgorithm"` })
type EncryptionKey ¶
type EncryptionKey []byte
func (EncryptionKey) VDLIsZero ¶
func (x EncryptionKey) VDLIsZero() bool
func (EncryptionKey) VDLReflect ¶
func (EncryptionKey) VDLReflect(struct { Name string `vdl:"v.io/x/ref/lib/discovery.EncryptionKey"` })
type Factory ¶
type Factory interface { // New creates a new Discovery.T instance. New(*context.T) (discovery.T, error) // Shutdown closes all Discovery.T instances and shutdowns the factory. Shutdown() }
Factory is the interface for creating a new discovery.T instance.
type Matcher ¶
type Matcher interface { // Match returns true if the matcher matches the advertisement. Match(ad *discovery.Advertisement) (bool, error) // TargetKey returns the key if a single key is being queried; otherwise // an empty string is returned. TargetKey() string // TargetInterfaceName returns the interface name if a single interface name // is being queried; otherwise an empty string is returned. TargetInterfaceName() string }
Matcher is the interface for matching advertisements against a query.
type Plugin ¶
type Plugin interface { // Advertise advertises the advertisement. // // The advertisement will not be changed while it is being advertised. // // If the advertisement is too large, the plugin may drop any information // except Id, InterfaceName, Hash, Timestamp, and DirAddrs. // // Advertising should continue until the context is canceled or exceeds // its deadline. done should be called once when advertising is done or // canceled. Advertise(ctx *context.T, adinfo *AdInfo, done func()) error // Scan scans advertisements that match the interface name and returns scanned // advertisements via the callback. // // An empty interface name means any advertisements. // // The callback takes ownership of the provided AdInfo, and the plugin // should not use the advertisement after invoking the callback. // // Scanning should continue until the context is canceled or exceeds its // deadline. done should be called once when scanning is done or canceled. Scan(ctx *context.T, interfaceName string, callback func(*AdInfo), done func()) error // Close closes the plugin. // // This will be called after all active tasks have been cancelled. Close() }
Plugin is the basic interface for discovery plugins.
All implementation should be goroutine-safe.
type Trigger ¶
type Trigger struct {
// contains filtered or unexported fields
}
A Trigger is a simple multi-channel receiver. It triggers callbacks when it receives signals from the corresponding channels. Each callback will run only once and run in a separate goroutine.
func NewTrigger ¶
func NewTrigger() *Trigger
type Uuid ¶
type Uuid []byte
func NewAttributeUUID ¶
NewAttributeUUID returns a version 5 UUID for the given name.
TODO(jhahn): rename to NewAttributeUuid.
func NewServiceUUID ¶
NewServiceUUID returns a version 5 UUID for the given interface name.
TODO(jhahn): rename to NewServiceUuid.
func (Uuid) VDLReflect ¶
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
TODO(jhahn): This is an experimental work to see its feasibility and set the long-term goal, and can be changed without notice.
|
TODO(jhahn): This is an experimental work to see its feasibility and set the long-term goal, and can be changed without notice. |
plugins
|
|
ble/corebluetooth
Package corebluetooth provides an implementation of ble.Driver using the CoreBluetooth Objective-C API The bridge rules between the two are as follows: THREADS: Everything in obj-c runs single threaded on a dedicated Grand Central Dispatch queue (read: thread).
|
Package corebluetooth provides an implementation of ble.Driver using the CoreBluetooth Objective-C API The bridge rules between the two are as follows: THREADS: Everything in obj-c runs single threaded on a dedicated Grand Central Dispatch queue (read: thread). |
loopback
Package loopback implements loopback plugin for discovery service.
|
Package loopback implements loopback plugin for discovery service. |
mdns
Package mdns implements mDNS plugin for discovery service.
|
Package mdns implements mDNS plugin for discovery service. |
vine
Package vine contains a discovery plugin that is using Vine protocol.
|
Package vine contains a discovery plugin that is using Vine protocol. |
package test contains tests that rely on a fake runtime.
|
package test contains tests that rely on a fake runtime. |
Package testutil defines helpers for discovery tests.
|
Package testutil defines helpers for discovery tests. |