announcement

package
v2.9.3+incompatible Latest Latest
Warning

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

Go to latest
Published: May 23, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCacheOptions = CacheOptions{
	ServiceCacheSize:       1000,
	ServiceCacheExpiration: 10 * time.Minute,
	ListCacheSize:          10,
	ListCacheExpiration:    10 * time.Second,
}

DefaultCacheOptions are the default CacheOptions

Functions

This section is empty.

Types

type Announcement

type Announcement struct {
	ID             string `redis:"id"`
	ServiceName    string `redis:"service_name"`
	ServiceVersion string `redis:"service_version"`
	Description    string `redis:"description"`
	URL            string `redis:"url"`
	Public         bool   `redis:"public"`
	NetAddress     string `redis:"net_address"`
	PublicKey      string `redis:"public_key"`
	Certificate    string `redis:"certificate"`
	APIAddress     string `redis:"api_address"`
	MQTTAddress    string `redis:"mqtt_address"`
	AMQPAddress    string `redis:"amqp_address"`
	Metadata       []Metadata

	CreatedAt time.Time `redis:"created_at"`
	UpdatedAt time.Time `redis:"updated_at"`
	// contains filtered or unexported fields
}

Announcement of a network component

func FromProto

func FromProto(a *pb.Announcement) Announcement

FromProto converts an Announcement protobuf to an Announcement

func (Announcement) ChangedFields

func (a Announcement) ChangedFields() (changed []string)

ChangedFields returns the names of the changed fields since the last call to StartUpdate

func (*Announcement) DBVersion

func (a *Announcement) DBVersion() string

DBVersion of the model

func (*Announcement) StartUpdate

func (a *Announcement) StartUpdate()

StartUpdate stores the state of the announcement

func (Announcement) ToProto

func (a Announcement) ToProto() *pb.Announcement

ToProto converts the Announcement to a protobuf Announcement

type AppEUIMetadata

type AppEUIMetadata struct {
	AppEUI types.AppEUI
}

AppEUIMetadata is used to store an AppEUI

func (AppEUIMetadata) MarshalText

func (m AppEUIMetadata) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface

func (AppEUIMetadata) ToProto

func (m AppEUIMetadata) ToProto() *pb.Metadata

ToProto implements the Metadata interface

type AppIDMetadata

type AppIDMetadata struct {
	AppID string
}

AppIDMetadata is used to store an AppID

func (AppIDMetadata) MarshalText

func (m AppIDMetadata) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface

func (AppIDMetadata) ToProto

func (m AppIDMetadata) ToProto() *pb.Metadata

ToProto implements the Metadata interface

type CacheOptions

type CacheOptions struct {
	ServiceCacheSize       int
	ServiceCacheExpiration time.Duration
	ListCacheSize          int
	ListCacheExpiration    time.Duration
}

CacheOptions used for the cache

type GatewayIDMetadata

type GatewayIDMetadata struct {
	GatewayID string
}

GatewayIDMetadata is used to store a GatewayID

func (GatewayIDMetadata) MarshalText

func (m GatewayIDMetadata) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface

func (GatewayIDMetadata) ToProto

func (m GatewayIDMetadata) ToProto() *pb.Metadata

ToProto implements the Metadata interface

type Metadata

type Metadata interface {
	encoding.TextMarshaler
	ToProto() *pb.Metadata
}

Metadata represents metadata that is stored with an Announcement

func MetadataFromProto

func MetadataFromProto(proto *pb.Metadata) Metadata

MetadataFromProto converts a protocol buffer metadata to a Metadata

func MetadataFromString

func MetadataFromString(str string) Metadata

MetadataFromString converts a string to a Metadata

type PrefixMetadata

type PrefixMetadata struct {
	Prefix types.DevAddrPrefix
}

PrefixMetadata is used to store a DevAddr prefix

func (PrefixMetadata) MarshalText

func (m PrefixMetadata) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface

func (PrefixMetadata) ToProto

func (m PrefixMetadata) ToProto() *pb.Metadata

ToProto implements the Metadata interface

type RedisAnnouncementStore

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

RedisAnnouncementStore stores Announcements in Redis. - Announcements are stored as a Hash - Metadata is stored in a Set - AppIDs and AppEUIs are indexed with key/value pairs

func (*RedisAnnouncementStore) AddMetadata

func (s *RedisAnnouncementStore) AddMetadata(serviceName, serviceID string, metadata ...Metadata) error

AddMetadata adds metadata to the announcement of the specified service

func (*RedisAnnouncementStore) Delete

func (s *RedisAnnouncementStore) Delete(serviceName, serviceID string) error

Delete an Announcement and its metadata

func (*RedisAnnouncementStore) Get

func (s *RedisAnnouncementStore) Get(serviceName, serviceID string) (*Announcement, error)

Get a specific service Announcement The result *does* include metadata

func (*RedisAnnouncementStore) GetForAppEUI

func (s *RedisAnnouncementStore) GetForAppEUI(appEUI types.AppEUI) (*Announcement, error)

GetForAppEUI returns the last Announcement that contains metadata for the given AppEUI

func (*RedisAnnouncementStore) GetForAppID

func (s *RedisAnnouncementStore) GetForAppID(appID string) (*Announcement, error)

GetForAppID returns the last Announcement that contains metadata for the given AppID

func (*RedisAnnouncementStore) GetForGatewayID

func (s *RedisAnnouncementStore) GetForGatewayID(gatewayID string) (*Announcement, error)

GetForGatewayID returns the last Announcement that contains metadata for the given GatewayID

func (*RedisAnnouncementStore) GetMetadata

func (s *RedisAnnouncementStore) GetMetadata(serviceName, serviceID string) ([]Metadata, error)

GetMetadata returns the metadata of the specified service

func (*RedisAnnouncementStore) List

List all Announcements The resulting Announcements do *not* include metadata

func (*RedisAnnouncementStore) ListService

func (s *RedisAnnouncementStore) ListService(serviceName string, opts *storage.ListOptions) ([]*Announcement, error)

ListService lists all Announcements for a given service (router/broker/handler) The resulting Announcements *do* include metadata

func (*RedisAnnouncementStore) RemoveMetadata

func (s *RedisAnnouncementStore) RemoveMetadata(serviceName, serviceID string, metadata ...Metadata) error

RemoveMetadata removes metadata from the announcement of the specified service

func (*RedisAnnouncementStore) Set

Set a new Announcement or update an existing one The metadata of the announcement is ignored, as metadata should be managed with AddMetadata and RemoveMetadata

type Store

type Store interface {
	List(opts *storage.ListOptions) ([]*Announcement, error)
	ListService(serviceName string, opts *storage.ListOptions) ([]*Announcement, error)
	Get(serviceName, serviceID string) (*Announcement, error)
	GetMetadata(serviceName, serviceID string) ([]Metadata, error)

	GetForAppID(appID string) (*Announcement, error)

	GetForGatewayID(gatewayID string) (*Announcement, error)

	GetForAppEUI(appEUI types.AppEUI) (*Announcement, error)
	Set(new *Announcement) error
	AddMetadata(serviceName, serviceID string, metadata ...Metadata) error
	RemoveMetadata(serviceName, serviceID string, metadata ...Metadata) error
	Delete(serviceName, serviceID string) error
	// contains filtered or unexported methods
}

Store interface for Announcements

func NewCachedAnnouncementStore

func NewCachedAnnouncementStore(store Store, options CacheOptions) Store

NewCachedAnnouncementStore returns a cache wrapper around the existing store

func NewRedisAnnouncementStore

func NewRedisAnnouncementStore(client *redis.Client, prefix string) Store

NewRedisAnnouncementStore creates a new Redis-based Announcement store

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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