discovery

package
v2.6.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2017 License: MIT Imports: 28 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
	GetServiceRequest
	GetRequest
	MetadataRequest
	AnnouncementsResponse

Package discovery is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

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 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

Functions

func RegisterDiscoveryHandler

func RegisterDiscoveryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterDiscoveryHandler registers the http handlers for service Discovery to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterDiscoveryHandlerFromEndpoint

func RegisterDiscoveryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterDiscoveryHandlerFromEndpoint is same as RegisterDiscoveryHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterDiscoveryManagerServer

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

func RegisterDiscoveryServer

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

Types

type Announcement

type Announcement struct {
	// The ID of the component
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// The name of the component (router/broker/handler)
	ServiceName string `protobuf:"bytes,2,opt,name=service_name,json=serviceName,proto3" json:"service_name,omitempty"`
	// Service version in the form "[version]-[commit] ([build date])"
	ServiceVersion string `protobuf:"bytes,3,opt,name=service_version,json=serviceVersion,proto3" json:"service_version,omitempty"`
	// Description of the component
	Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"`
	// URL with documentation or more information about this component
	Url string `protobuf:"bytes,5,opt,name=url,proto3" json:"url,omitempty"`
	// Indicates whether this service is part of The Things Network (the public community network)
	Public bool `protobuf:"varint,6,opt,name=public,proto3" json:"public,omitempty"`
	// Comma-separated network addresses in the form "domain1:port,domain2:port,domain3:port" (currently we only use the first)
	NetAddress string `protobuf:"bytes,11,opt,name=net_address,json=netAddress,proto3" json:"net_address,omitempty"`
	// ECDSA public key of this component
	PublicKey string `protobuf:"bytes,12,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
	// TLS Certificate for gRPC on net_address (if TLS is enabled)
	Certificate string `protobuf:"bytes,13,opt,name=certificate,proto3" json:"certificate,omitempty"`
	// Contains the address where the HTTP API is exposed (if there is one).
	// Format of api_address: `http(s)://domain(:port)`
	// default http port is 80, default https port is 443.
	ApiAddress string `protobuf:"bytes,14,opt,name=api_address,json=apiAddress,proto3" json:"api_address,omitempty"`
	// Contains the address where the MQTT API is exposed (if there is one)
	// Format of mqtt_address: `(mqtt(s)://)host(:port)`
	// default mqtt port is 1883, default mqtts port is 8883.
	// Examples:
	// if `host:port` then `mqtt://host:port`
	// if `host:8883` then `mqtts://host:8883`
	// if `host` then `mqtt://host:1883` and `mqtts://host:8883`
	// if `mqtt://host` then `mqtt://host:1883`
	// if `mqtts://host` then `mqtt://host:1883` and `mqtts://host:8883`
	MqttAddress string `protobuf:"bytes,15,opt,name=mqtt_address,json=mqttAddress,proto3" json:"mqtt_address,omitempty"`
	// Contains the address where the AMQP API is exposed (if there is one)
	// Format of amqp_address: `(amqp(s)://)host(:port)`
	// default amqp port is 5672, default amqps port is 5671.
	// Examples:
	// if `host:port` then `amqp://host:port`
	// if `host:5671` then `amqps://host:5671`
	// if `host` then `amqp://host:5672` and `amqps://host:5671`
	// if `amqp://host` then `amqp://host:5672`
	// if `amqps://host` then `amqp://host:5672` and `amqps://host:5671`
	AmqpAddress string `protobuf:"bytes,16,opt,name=amqp_address,json=amqpAddress,proto3" json:"amqp_address,omitempty"`
	// Metadata for this component
	Metadata []*Metadata `protobuf:"bytes,22,rep,name=metadata" json:"metadata,omitempty"`
}

The Announcement of a service (also called component)

func (*Announcement) AppEUIs

func (a *Announcement) AppEUIs() (euis []types.AppEUI)

AppEUIs that are handled by this component

func (*Announcement) AppIDs

func (a *Announcement) AppIDs() (appIDs []string)

AppIDs that are handled by this component

func (*Announcement) Descriptor

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

func (*Announcement) DevAddrPrefixes

func (a *Announcement) DevAddrPrefixes() (prefixes []types.DevAddrPrefix)

DevAddrPrefixes that are handled by this component

func (*Announcement) Dial

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

Dial the component represented by this Announcement. This function is blocking if the pool uses grpc.WithBlock()

func (*Announcement) GetAmqpAddress

func (m *Announcement) GetAmqpAddress() string

func (*Announcement) GetApiAddress

func (m *Announcement) GetApiAddress() string

func (*Announcement) GetCertificate

func (m *Announcement) GetCertificate() string

func (*Announcement) GetDescription

func (m *Announcement) GetDescription() string

func (*Announcement) GetId

func (m *Announcement) GetId() string

func (*Announcement) GetMetadata

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

func (*Announcement) GetMqttAddress

func (m *Announcement) GetMqttAddress() string

func (*Announcement) GetNetAddress

func (m *Announcement) GetNetAddress() string

func (*Announcement) GetPublic

func (m *Announcement) GetPublic() bool

func (*Announcement) GetPublicKey

func (m *Announcement) GetPublicKey() string

func (*Announcement) GetServiceName

func (m *Announcement) GetServiceName() string

func (*Announcement) GetServiceVersion

func (m *Announcement) GetServiceVersion() string

func (*Announcement) GetUrl

func (m *Announcement) GetUrl() string

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) TLSConfig

func (a *Announcement) TLSConfig() (*tls.Config, error)

TLSConfig for securely connecting with this component

func (*Announcement) Unmarshal

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

func (*Announcement) Validate

func (m *Announcement) Validate() error

Validate implements the api.Validator interface

func (*Announcement) WithSecure

func (a *Announcement) WithSecure() grpc.DialOption

WithSecure returns a gRPC DialOption with TLS

type AnnouncementsResponse

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

A list of announcements

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)
	AddDevAddrPrefix(prefix types.DevAddrPrefix) error
	AddAppID(appID string, token string) error
	RemoveDevAddrPrefix(prefix types.DevAddrPrefix) error
	RemoveAppID(appID string, token string) 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) AddAppID

func (c *DefaultClient) AddAppID(appID string, token string) error

AddAppID adds an AppID to the current component

func (*DefaultClient) AddDevAddrPrefix

func (c *DefaultClient) AddDevAddrPrefix(prefix types.DevAddrPrefix) error

AddDevAddrPrefix adds a DevAddrPrefix to the current component

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) 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) (announcements []*Announcement, err error)

GetAllBrokersForDevAddr returns all brokers that can handle the given DevAddr

func (*DefaultClient) GetAllHandlersForAppID

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

GetAllHandlersForAppID returns all handlers that can handle the given AppID

func (*DefaultClient) RemoveAppID

func (c *DefaultClient) RemoveAppID(appID string, token string) error

RemoveAppID removes an AppID from the current component

func (*DefaultClient) RemoveDevAddrPrefix

func (c *DefaultClient) RemoveDevAddrPrefix(prefix types.DevAddrPrefix) error

RemoveDevAddrPrefix removes a DevAddrPrefix from the current component

type DiscoveryClient

type DiscoveryClient interface {
	// Announce a component to the Discovery server.
	// A call to `Announce` does not processes the `metadata` field, so you can safely leave this field empty.
	// Adding or removing Metadata should be done with the `AddMetadata` and `DeleteMetadata` methods.
	Announce(ctx context.Context, in *Announcement, opts ...grpc.CallOption) (*google_protobuf.Empty, error)
	// Get all announcements for a specific service type
	GetAll(ctx context.Context, in *GetServiceRequest, opts ...grpc.CallOption) (*AnnouncementsResponse, error)
	// Get a specific announcement
	Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*Announcement, error)
	// Add metadata to an announement
	AddMetadata(ctx context.Context, in *MetadataRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error)
	// Delete metadata from an announcement
	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 DiscoveryServer

type DiscoveryServer interface {
	// Announce a component to the Discovery server.
	// A call to `Announce` does not processes the `metadata` field, so you can safely leave this field empty.
	// Adding or removing Metadata should be done with the `AddMetadata` and `DeleteMetadata` methods.
	Announce(context.Context, *Announcement) (*google_protobuf.Empty, error)
	// Get all announcements for a specific service type
	GetAll(context.Context, *GetServiceRequest) (*AnnouncementsResponse, error)
	// Get a specific announcement
	Get(context.Context, *GetRequest) (*Announcement, error)
	// Add metadata to an announement
	AddMetadata(context.Context, *MetadataRequest) (*google_protobuf.Empty, error)
	// Delete metadata from an announcement
	DeleteMetadata(context.Context, *MetadataRequest) (*google_protobuf.Empty, error)
}

type GetRequest

type GetRequest struct {
	// The ID of the service
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// The name of the service (router/broker/handler)
	ServiceName string `protobuf:"bytes,2,opt,name=service_name,json=serviceName,proto3" json:"service_name,omitempty"`
}

The identifier of the service that should be returned

func (*GetRequest) Descriptor

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

func (*GetRequest) GetId

func (m *GetRequest) GetId() string

func (*GetRequest) GetServiceName

func (m *GetRequest) GetServiceName() string

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 GetServiceRequest

type GetServiceRequest struct {
	// The name of the service (router/broker/handler)
	ServiceName string `protobuf:"bytes,1,opt,name=service_name,json=serviceName,proto3" json:"service_name,omitempty"`
}

func (*GetServiceRequest) Descriptor

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

func (*GetServiceRequest) GetServiceName

func (m *GetServiceRequest) GetServiceName() string

func (*GetServiceRequest) Marshal

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

func (*GetServiceRequest) MarshalTo

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

func (*GetServiceRequest) ProtoMessage

func (*GetServiceRequest) ProtoMessage()

func (*GetServiceRequest) Reset

func (m *GetServiceRequest) Reset()

func (*GetServiceRequest) Size

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

func (*GetServiceRequest) String

func (m *GetServiceRequest) String() string

func (*GetServiceRequest) Unmarshal

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

type Metadata

type Metadata struct {
	// Types that are valid to be assigned to Metadata:
	//	*Metadata_DevAddrPrefix
	//	*Metadata_AppId
	//	*Metadata_AppEui
	Metadata isMetadata_Metadata `protobuf_oneof:"metadata"`
}

func (*Metadata) Descriptor

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

func (*Metadata) GetAppEui

func (m *Metadata) GetAppEui() []byte

func (*Metadata) GetAppId

func (m *Metadata) GetAppId() string

func (*Metadata) GetDevAddrPrefix

func (m *Metadata) GetDevAddrPrefix() []byte

func (*Metadata) GetMetadata

func (m *Metadata) GetMetadata() isMetadata_Metadata

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

func (*Metadata) XXX_OneofFuncs

func (*Metadata) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{})

XXX_OneofFuncs is for the internal use of the proto package.

type MetadataRequest

type MetadataRequest struct {
	// The ID of the service that should be modified
	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	// The name of the service (router/broker/handler) that should be modified
	ServiceName string `protobuf:"bytes,2,opt,name=service_name,json=serviceName,proto3" json:"service_name,omitempty"`
	// Metadata to add or remove
	Metadata *Metadata `protobuf:"bytes,12,opt,name=metadata" json:"metadata,omitempty"`
}

The metadata to add or remove from an announement

func (*MetadataRequest) Descriptor

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

func (*MetadataRequest) GetId

func (m *MetadataRequest) GetId() string

func (*MetadataRequest) GetMetadata

func (m *MetadataRequest) GetMetadata() *Metadata

func (*MetadataRequest) GetServiceName

func (m *MetadataRequest) GetServiceName() string

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_AppEui

type Metadata_AppEui struct {
	AppEui []byte `protobuf:"bytes,31,opt,name=app_eui,json=appEui,proto3,oneof"`
}

func (*Metadata_AppEui) MarshalTo

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

func (*Metadata_AppEui) Size

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

type Metadata_AppId

type Metadata_AppId struct {
	AppId string `protobuf:"bytes,30,opt,name=app_id,json=appId,proto3,oneof"`
}

func (*Metadata_AppId) MarshalTo

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

func (*Metadata_AppId) Size

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

type Metadata_DevAddrPrefix

type Metadata_DevAddrPrefix struct {
	DevAddrPrefix []byte `protobuf:"bytes,20,opt,name=dev_addr_prefix,json=devAddrPrefix,proto3,oneof"`
}

func (*Metadata_DevAddrPrefix) MarshalTo

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

func (*Metadata_DevAddrPrefix) Size

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

type MockClient

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

Mock of Client interface

func NewMockClient

func NewMockClient(ctrl *gomock.Controller) *MockClient

func (*MockClient) AddAppID

func (_m *MockClient) AddAppID(appID string, token string) error

func (*MockClient) AddDevAddrPrefix

func (_m *MockClient) AddDevAddrPrefix(prefix types.DevAddrPrefix) error

func (*MockClient) Announce

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

func (*MockClient) Close

func (_m *MockClient) Close() 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) GetAllHandlersForAppID

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

func (*MockClient) RemoveAppID

func (_m *MockClient) RemoveAppID(appID string, token string) error

func (*MockClient) RemoveDevAddrPrefix

func (_m *MockClient) RemoveDevAddrPrefix(prefix types.DevAddrPrefix) error

Jump to

Keyboard shortcuts

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