discovery

package
v0.0.0-...-2f095fc Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2016 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package discovery is a generated protocol buffer package.

It is generated from these files:

github.com/TheThingsNetwork/ttn/api/discovery/discovery.proto

It has these top-level messages:

Metadata
Announcement
GetAllRequest
GetRequest
MetadataRequest
AnnouncementsResponse

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthDiscovery = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowDiscovery   = fmt.Errorf("proto: integer overflow")
)
View Source
var AnnouncementProperties = []string{
	"id",
	"description",
	"service_name",
	"service_version",
	"net_address",
	"public_key",
	"certificate",
	"metadata",
}

AnnouncementProperties contains all properties of an Announcement that can be stored in Redis.

View Source
var CacheExpiration = 5 * time.Minute

CacheExpiration indicates the time a cached item is valid

View Source
var CacheSize = 1000

CacheSize indicates the number of components that are cached

View Source
var Metadata_Key_name = map[int32]string{
	0: "OTHER",
	1: "PREFIX",
	2: "APP_EUI",
	3: "APP_ID",
}
View Source
var Metadata_Key_value = map[string]int32{
	"OTHER":   0,
	"PREFIX":  1,
	"APP_EUI": 2,
	"APP_ID":  3,
}

Functions

func RegisterDiscoveryManagerServer

func RegisterDiscoveryManagerServer(s *grpc.Server, srv DiscoveryManagerServer)

func RegisterDiscoveryServer

func RegisterDiscoveryServer(s *grpc.Server, srv DiscoveryServer)

Types

type Announcement

type Announcement struct {
	Id             string      `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	ServiceName    string      `protobuf:"bytes,2,opt,name=service_name,json=serviceName,proto3" json:"service_name,omitempty"`
	ServiceVersion string      `protobuf:"bytes,3,opt,name=service_version,json=serviceVersion,proto3" json:"service_version,omitempty"`
	Description    string      `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"`
	Url            string      `protobuf:"bytes,5,opt,name=url,proto3" json:"url,omitempty"`
	Public         bool        `protobuf:"varint,6,opt,name=public,proto3" json:"public,omitempty"`
	NetAddress     string      `protobuf:"bytes,11,opt,name=net_address,json=netAddress,proto3" json:"net_address,omitempty"`
	PublicKey      string      `protobuf:"bytes,12,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
	Certificate    string      `protobuf:"bytes,13,opt,name=certificate,proto3" json:"certificate,omitempty"`
	Metadata       []*Metadata `protobuf:"bytes,21,rep,name=metadata" json:"metadata,omitempty"`
}

func (*Announcement) AddMetadata

func (announcement *Announcement) AddMetadata(key Metadata_Key, value []byte)

AddMetadata adds metadata to the announcement if it doesn't exist

func (*Announcement) DeleteMetadata

func (announcement *Announcement) DeleteMetadata(key Metadata_Key, value []byte)

DeleteMetadata deletes metadata from the announcement if it exists

func (*Announcement) Descriptor

func (*Announcement) Descriptor() ([]byte, []int)

func (*Announcement) Dial

func (a *Announcement) Dial() (*grpc.ClientConn, error)

Dial dials the component represented by this Announcement

func (*Announcement) FromStringStringMap

func (announcement *Announcement) FromStringStringMap(input map[string]string) error

FromStringStringMap imports known values from the input to a Status.

func (*Announcement) GetMetadata

func (m *Announcement) GetMetadata() []*Metadata

func (*Announcement) Marshal

func (m *Announcement) Marshal() (dAtA []byte, err error)

func (*Announcement) MarshalTo

func (m *Announcement) MarshalTo(dAtA []byte) (int, error)

func (*Announcement) ProtoMessage

func (*Announcement) ProtoMessage()

func (*Announcement) Reset

func (m *Announcement) Reset()

func (*Announcement) Size

func (m *Announcement) Size() (n int)

func (*Announcement) String

func (m *Announcement) String() string

func (*Announcement) ToStringStringMap

func (announcement *Announcement) ToStringStringMap(properties ...string) (map[string]string, error)

ToStringStringMap converts the given properties of Announcement to a map[string]string for storage in Redis.

func (*Announcement) Unmarshal

func (m *Announcement) Unmarshal(dAtA []byte) error

func (*Announcement) Validate

func (m *Announcement) Validate() error

Validate implements the api.Validator interface

type AnnouncementsResponse

type AnnouncementsResponse struct {
	Services []*Announcement `protobuf:"bytes,1,rep,name=services" json:"services,omitempty"`
}

func (*AnnouncementsResponse) Descriptor

func (*AnnouncementsResponse) Descriptor() ([]byte, []int)

func (*AnnouncementsResponse) GetServices

func (m *AnnouncementsResponse) GetServices() []*Announcement

func (*AnnouncementsResponse) Marshal

func (m *AnnouncementsResponse) Marshal() (dAtA []byte, err error)

func (*AnnouncementsResponse) MarshalTo

func (m *AnnouncementsResponse) MarshalTo(dAtA []byte) (int, error)

func (*AnnouncementsResponse) ProtoMessage

func (*AnnouncementsResponse) ProtoMessage()

func (*AnnouncementsResponse) Reset

func (m *AnnouncementsResponse) Reset()

func (*AnnouncementsResponse) Size

func (m *AnnouncementsResponse) Size() (n int)

func (*AnnouncementsResponse) String

func (m *AnnouncementsResponse) String() string

func (*AnnouncementsResponse) Unmarshal

func (m *AnnouncementsResponse) Unmarshal(dAtA []byte) error

type Client

type Client interface {
	Announce(token string) error
	GetAll(serviceName string) ([]*Announcement, error)
	Get(serviceName, id string) (*Announcement, error)
	AddMetadata(key Metadata_Key, value []byte, token string) error
	DeleteMetadata(key Metadata_Key, value []byte, token string) error
	GetAllForMetadata(serviceName string, key Metadata_Key, matchFunc func(value []byte) bool) ([]*Announcement, error)
	GetAllBrokersForDevAddr(devAddr types.DevAddr) ([]*Announcement, error)
	GetAllHandlersForAppID(appID string) ([]*Announcement, error)
	Close() error
}

Client is used as the main client to the Discovery server

func NewClient

func NewClient(server string, announcement *Announcement, tokenFunc func() string) (Client, error)

NewClient returns a new Client

type DefaultClient

type DefaultClient struct {
	sync.Mutex
	// contains filtered or unexported fields
}

DefaultClient is a wrapper around DiscoveryClient

func (*DefaultClient) AddMetadata

func (c *DefaultClient) AddMetadata(key Metadata_Key, value []byte, token string) error

AddMetadata publishes metadata for the current component to the Discovery server

func (*DefaultClient) Announce

func (c *DefaultClient) Announce(token string) error

Announce announces the configured announcement to the discovery server

func (*DefaultClient) Close

func (c *DefaultClient) Close() error

Close purges the cache and closes the connection with the Discovery server

func (*DefaultClient) DeleteMetadata

func (c *DefaultClient) DeleteMetadata(key Metadata_Key, value []byte, token string) error

DeleteMetadata deletes metadata for the current component from the Discovery server

func (*DefaultClient) Get

func (c *DefaultClient) Get(serviceName, id string) (*Announcement, error)

Get returns the (cached) service annoucement for the given service type and id

func (*DefaultClient) GetAll

func (c *DefaultClient) GetAll(serviceName string) ([]*Announcement, error)

GetAll returns all services of the given service type

func (*DefaultClient) GetAllBrokersForDevAddr

func (c *DefaultClient) GetAllBrokersForDevAddr(devAddr types.DevAddr) ([]*Announcement, error)

GetAllBrokersForDevAddr returns all brokers that can handle the given DevAddr

func (*DefaultClient) GetAllForMetadata

func (c *DefaultClient) GetAllForMetadata(serviceName string, key Metadata_Key, matchFunc func(value []byte) bool) ([]*Announcement, error)

GetAllForMetadata returns all annoucements of given type that contain given metadata and match the given function

func (*DefaultClient) GetAllHandlersForAppID

func (c *DefaultClient) GetAllHandlersForAppID(appID string) ([]*Announcement, error)

GetAllHandlersForAppID returns all handlers that can handle the given AppID

type DiscoveryClient

type DiscoveryClient interface {
	Announce(ctx context.Context, in *Announcement, opts ...grpc.CallOption) (*google_protobuf.Empty, error)
	GetAll(ctx context.Context, in *GetAllRequest, opts ...grpc.CallOption) (*AnnouncementsResponse, error)
	Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*Announcement, error)
	AddMetadata(ctx context.Context, in *MetadataRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error)
	DeleteMetadata(ctx context.Context, in *MetadataRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error)
}

func NewDiscoveryClient

func NewDiscoveryClient(cc *grpc.ClientConn) DiscoveryClient

type DiscoveryManagerClient

type DiscoveryManagerClient interface {
}

func NewDiscoveryManagerClient

func NewDiscoveryManagerClient(cc *grpc.ClientConn) DiscoveryManagerClient

type DiscoveryManagerServer

type DiscoveryManagerServer interface {
}

type GetAllRequest

type GetAllRequest struct {
	ServiceName string `protobuf:"bytes,1,opt,name=service_name,json=serviceName,proto3" json:"service_name,omitempty"`
}

func (*GetAllRequest) Descriptor

func (*GetAllRequest) Descriptor() ([]byte, []int)

func (*GetAllRequest) Marshal

func (m *GetAllRequest) Marshal() (dAtA []byte, err error)

func (*GetAllRequest) MarshalTo

func (m *GetAllRequest) MarshalTo(dAtA []byte) (int, error)

func (*GetAllRequest) ProtoMessage

func (*GetAllRequest) ProtoMessage()

func (*GetAllRequest) Reset

func (m *GetAllRequest) Reset()

func (*GetAllRequest) Size

func (m *GetAllRequest) Size() (n int)

func (*GetAllRequest) String

func (m *GetAllRequest) String() string

func (*GetAllRequest) Unmarshal

func (m *GetAllRequest) Unmarshal(dAtA []byte) error

type GetRequest

type GetRequest struct {
	Id          string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	ServiceName string `protobuf:"bytes,2,opt,name=service_name,json=serviceName,proto3" json:"service_name,omitempty"`
}

func (*GetRequest) Descriptor

func (*GetRequest) Descriptor() ([]byte, []int)

func (*GetRequest) Marshal

func (m *GetRequest) Marshal() (dAtA []byte, err error)

func (*GetRequest) MarshalTo

func (m *GetRequest) MarshalTo(dAtA []byte) (int, error)

func (*GetRequest) ProtoMessage

func (*GetRequest) ProtoMessage()

func (*GetRequest) Reset

func (m *GetRequest) Reset()

func (*GetRequest) Size

func (m *GetRequest) Size() (n int)

func (*GetRequest) String

func (m *GetRequest) String() string

func (*GetRequest) Unmarshal

func (m *GetRequest) Unmarshal(dAtA []byte) error

type Metadata

type Metadata struct {
	Key   Metadata_Key `protobuf:"varint,1,opt,name=key,proto3,enum=discovery.Metadata_Key" json:"key,omitempty"`
	Value []byte       `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
}

func (*Metadata) Descriptor

func (*Metadata) Descriptor() ([]byte, []int)

func (*Metadata) Marshal

func (m *Metadata) Marshal() (dAtA []byte, err error)

func (*Metadata) MarshalTo

func (m *Metadata) MarshalTo(dAtA []byte) (int, error)

func (*Metadata) ProtoMessage

func (*Metadata) ProtoMessage()

func (*Metadata) Reset

func (m *Metadata) Reset()

func (*Metadata) Size

func (m *Metadata) Size() (n int)

func (*Metadata) String

func (m *Metadata) String() string

func (*Metadata) Unmarshal

func (m *Metadata) Unmarshal(dAtA []byte) error

type MetadataRequest

type MetadataRequest struct {
	Id          string    `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	ServiceName string    `protobuf:"bytes,2,opt,name=service_name,json=serviceName,proto3" json:"service_name,omitempty"`
	Metadata    *Metadata `protobuf:"bytes,11,opt,name=metadata" json:"metadata,omitempty"`
}

func (*MetadataRequest) Descriptor

func (*MetadataRequest) Descriptor() ([]byte, []int)

func (*MetadataRequest) GetMetadata

func (m *MetadataRequest) GetMetadata() *Metadata

func (*MetadataRequest) Marshal

func (m *MetadataRequest) Marshal() (dAtA []byte, err error)

func (*MetadataRequest) MarshalTo

func (m *MetadataRequest) MarshalTo(dAtA []byte) (int, error)

func (*MetadataRequest) ProtoMessage

func (*MetadataRequest) ProtoMessage()

func (*MetadataRequest) Reset

func (m *MetadataRequest) Reset()

func (*MetadataRequest) Size

func (m *MetadataRequest) Size() (n int)

func (*MetadataRequest) String

func (m *MetadataRequest) String() string

func (*MetadataRequest) Unmarshal

func (m *MetadataRequest) Unmarshal(dAtA []byte) error

type Metadata_Key

type Metadata_Key int32
const (
	Metadata_OTHER Metadata_Key = 0
	// The value for PREFIX consists of 1 byte denoting the number of bits,
	// followed by the prefix and enough trailing bits to fill 4 octets
	Metadata_PREFIX Metadata_Key = 1
	// APP_EUI is used for announcing join handlers.
	// The value for APP_EUI is the byte slice of the AppEUI string
	Metadata_APP_EUI Metadata_Key = 2
	// APP_ID is used for announcing regular handlers
	// The value for APP_ID is the byte slice of the AppID string
	Metadata_APP_ID Metadata_Key = 3
)

func (Metadata_Key) EnumDescriptor

func (Metadata_Key) EnumDescriptor() ([]byte, []int)

func (Metadata_Key) String

func (x Metadata_Key) String() string

type MockClient

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

Mock of Client interface

func NewMockClient

func NewMockClient(ctrl *gomock.Controller) *MockClient

func (*MockClient) AddMetadata

func (_m *MockClient) AddMetadata(key Metadata_Key, value []byte, token string) error

func (*MockClient) Announce

func (_m *MockClient) Announce(token string) error

func (*MockClient) Close

func (_m *MockClient) Close() error

func (*MockClient) DeleteMetadata

func (_m *MockClient) DeleteMetadata(key Metadata_Key, value []byte, token string) error

func (*MockClient) EXPECT

func (_m *MockClient) EXPECT() *_MockClientRecorder

func (*MockClient) Get

func (_m *MockClient) Get(serviceName string, id string) (*Announcement, error)

func (*MockClient) GetAll

func (_m *MockClient) GetAll(serviceName string) ([]*Announcement, error)

func (*MockClient) GetAllBrokersForDevAddr

func (_m *MockClient) GetAllBrokersForDevAddr(devAddr types.DevAddr) ([]*Announcement, error)

func (*MockClient) GetAllForMetadata

func (_m *MockClient) GetAllForMetadata(serviceName string, key Metadata_Key, matchFunc func([]byte) bool) ([]*Announcement, error)

func (*MockClient) GetAllHandlersForAppID

func (_m *MockClient) GetAllHandlersForAppID(appID string) ([]*Announcement, error)

Jump to

Keyboard shortcuts

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