client

package
v2.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrFunc

type ErrFunc = func(err error)

ErrFunc reports errors

type OwnerCache

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

func NewOwnerCache

func NewOwnerCache(ownerClaim string, expiration time.Duration, conn *nats.Conn, isClient pbIS.IdentityStoreClient, errFunc ErrFunc) *OwnerCache

func (*OwnerCache) Close

func (c *OwnerCache) Close()

func (*OwnerCache) GetDevices

func (c *OwnerCache) GetDevices(ctx context.Context) (devices []string, err error)

GetDevices provides the owner of the cached device. If the cache does not expire, the cache expiration is extended.

func (*OwnerCache) GetSelectedDevices

func (c *OwnerCache) GetSelectedDevices(ctx context.Context, devices []string) ([]string, error)

Check provided list of device ids and return only ids owned by the user

func (*OwnerCache) OwnerClaim

func (c *OwnerCache) OwnerClaim() string

func (*OwnerCache) OwnsDevice

func (c *OwnerCache) OwnsDevice(ctx context.Context, deviceID string) (bool, error)

Convenience method to check if given device is owned by the user

func (*OwnerCache) OwnsDevices

func (c *OwnerCache) OwnsDevices(ctx context.Context, devices []string) (bool, error)

Check if all provided devices are owned by the user

func (*OwnerCache) Subscribe

func (c *OwnerCache) Subscribe(owner string, onEvent func(e *events.Event)) (func(), error)

Subscribe register onEvents handler and creates a NATS subscription, if it does not exist. To free subscription call the returned close function.

func (*OwnerCache) Update

func (c *OwnerCache) Update(ctx context.Context) (added []string, removed []string, err error)

Update updates devices in cache and subscribe to NATS for updating them.

Jump to

Keyboard shortcuts

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