Documentation ¶
Index ¶
- Constants
- type DirectoryService
- type ReadDirectoryService
- func (svc *ReadDirectoryService) CreateReadDirTD() *thing.TD
- func (svc *ReadDirectoryService) First(ctx hubclient.ServiceContext, args directoryapi.CursorFirstArgs) (*directoryapi.CursorFirstResp, error)
- func (svc *ReadDirectoryService) GetCursor(ctx hubclient.ServiceContext) (*directoryapi.GetCursorResp, error)
- func (svc *ReadDirectoryService) GetTD(ctx hubclient.ServiceContext, args *directoryapi.GetTDArgs) (resp *directoryapi.GetTDResp, err error)
- func (svc *ReadDirectoryService) GetTDs(ctx hubclient.ServiceContext, args *directoryapi.GetTDsArgs) (res *directoryapi.GetTDsResp, err error)
- func (svc *ReadDirectoryService) GetTDsRaw(ctx hubclient.ServiceContext, args *directoryapi.GetTDsArgs) (map[string][]byte, error)
- func (svc *ReadDirectoryService) Next(ctx hubclient.ServiceContext, args directoryapi.CursorNextArgs) (*directoryapi.CursorNextResp, error)
- func (svc *ReadDirectoryService) NextN(ctx hubclient.ServiceContext, args directoryapi.CursorNextNArgs) (*directoryapi.CursorNextNResp, error)
- func (svc *ReadDirectoryService) Release(ctx hubclient.ServiceContext, args directoryapi.CursorReleaseArgs) error
- func (svc *ReadDirectoryService) Stop()
- type UpdateDirectoryService
- func (svc *UpdateDirectoryService) CreateUpdateDirTD() *thing.TD
- func (svc *UpdateDirectoryService) RemoveTD(ctx hubclient.ServiceContext, args directoryapi.RemoveTDArgs) error
- func (svc *UpdateDirectoryService) Stop()
- func (svc *UpdateDirectoryService) UpdateTD(ctx hubclient.ServiceContext, args directoryapi.UpdateTDArgs) error
Constants ¶
const TDBucketName = "td"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DirectoryService ¶
type DirectoryService struct {
// contains filtered or unexported fields
}
DirectoryService is a wrapper around the internal store store This implements the IDirectory interface
func NewDirectoryService ¶
func NewDirectoryService( hc *hubclient.HubClient, store buckets.IBucketStore) *DirectoryService
NewDirectoryService creates an agent that provides capabilities to access TD documents The servicePubSub is optional and ignored when nil. It is used to subscribe to directory events and will be released on Stop.
hc is the hub client connection to use with this agent. Its ID is used as the agentID that provides the capability. store is an open store store containing the directory data.
func (*DirectoryService) Start ¶
func (svc *DirectoryService) Start() (err error)
Start the directory service and publish the service's own TD This subscribes to pubsub TD events and updates the directory.
type ReadDirectoryService ¶
type ReadDirectoryService struct {
// contains filtered or unexported fields
}
ReadDirectoryService is a provides the capability to read and iterate the directory
func StartReadDirectoryService ¶
func StartReadDirectoryService(hc *hubclient.HubClient, bucket buckets.IBucket) ( svc *ReadDirectoryService, err error)
StartReadDirectoryService starts the capability to read the directory hc with the message bus connection. Its ID will be used as the agentID that provides the capability. bucket is an open store bucket for reading the TD data.
func (*ReadDirectoryService) CreateReadDirTD ¶
func (svc *ReadDirectoryService) CreateReadDirTD() *thing.TD
CreateReadDirTD creates a Thing TD document describing the read directory capability
func (*ReadDirectoryService) First ¶
func (svc *ReadDirectoryService) First( ctx hubclient.ServiceContext, args directoryapi.CursorFirstArgs) (*directoryapi.CursorFirstResp, error)
First returns the first entry in the directory
func (*ReadDirectoryService) GetCursor ¶
func (svc *ReadDirectoryService) GetCursor( ctx hubclient.ServiceContext) (*directoryapi.GetCursorResp, error)
GetCursor returns an iterator for ThingValues containing a TD document The lifespan is currently fixed to 1 minute.
clientID is the owner of the cursor. Used to remove all cursors of an owner when it disconnects.
func (*ReadDirectoryService) GetTD ¶
func (svc *ReadDirectoryService) GetTD( ctx hubclient.ServiceContext, args *directoryapi.GetTDArgs) (resp *directoryapi.GetTDResp, err error)
GetTD returns the TD document for the given Thing ID in JSON format
func (*ReadDirectoryService) GetTDs ¶
func (svc *ReadDirectoryService) GetTDs( ctx hubclient.ServiceContext, args *directoryapi.GetTDsArgs) (res *directoryapi.GetTDsResp, err error)
GetTDs returns a collection of TD documents this is rather inefficient. Should the client do the unmarshalling of the docs array? that would break the matching API. Maybe an internal method that returns a raw batch?
func (*ReadDirectoryService) GetTDsRaw ¶
func (svc *ReadDirectoryService) GetTDsRaw( ctx hubclient.ServiceContext, args *directoryapi.GetTDsArgs) (map[string][]byte, error)
GetTDsRaw returns a collection of ThingValue documents Intended for transferring documents without unnecessary marshalling
func (*ReadDirectoryService) Next ¶
func (svc *ReadDirectoryService) Next( ctx hubclient.ServiceContext, args directoryapi.CursorNextArgs) (*directoryapi.CursorNextResp, error)
Next moves the cursor to the next key from the current cursor First() or Seek must have been called first. Shouldn't next have a parameter?
func (*ReadDirectoryService) NextN ¶
func (svc *ReadDirectoryService) NextN( ctx hubclient.ServiceContext, args directoryapi.CursorNextNArgs) (*directoryapi.CursorNextNResp, error)
NextN moves the cursor to the next N places from the current cursor and return a list with N values in incremental time order. itemsRemaining is false if the iterator has reached the end. Intended to speed up with batch iterations over rpc.
func (*ReadDirectoryService) Release ¶
func (svc *ReadDirectoryService) Release( ctx hubclient.ServiceContext, args directoryapi.CursorReleaseArgs) error
Release close the cursor and release its resources. This invalidates all values obtained from the cursor
func (*ReadDirectoryService) Stop ¶
func (svc *ReadDirectoryService) Stop()
Stop the read directory capability this unsubscribes from requests and stops the cursor cleanup task.
type UpdateDirectoryService ¶
type UpdateDirectoryService struct {
// contains filtered or unexported fields
}
UpdateDirectoryService is a provides the capability to update the directory This implements the IUpdateDirectory API
Bucket keys are made of gatewayID+"/"+thingID Bucket values are ThingValue objects
func StartUpdateDirectoryService ¶
func StartUpdateDirectoryService(hc *hubclient.HubClient, bucket buckets.IBucket) ( svc *UpdateDirectoryService, err error)
StartUpdateDirectoryService starts the capability to update the directory. Invoke Stop() when done to unsubscribe from requests.
hc with the message bus connection thingBucket is the open bucket used to store TDs
func (*UpdateDirectoryService) CreateUpdateDirTD ¶
func (svc *UpdateDirectoryService) CreateUpdateDirTD() *thing.TD
CreateUpdateDirTD a new Thing TD document describing the update directory capability
func (*UpdateDirectoryService) RemoveTD ¶
func (svc *UpdateDirectoryService) RemoveTD(ctx hubclient.ServiceContext, args directoryapi.RemoveTDArgs) error
func (*UpdateDirectoryService) Stop ¶
func (svc *UpdateDirectoryService) Stop()
Stop the update directory capability This unsubscribes from requests.
func (*UpdateDirectoryService) UpdateTD ¶
func (svc *UpdateDirectoryService) UpdateTD(ctx hubclient.ServiceContext, args directoryapi.UpdateTDArgs) error