metathings_component

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2019 License: MIT Imports: 40 Imported by: 17

Documentation

Index

Constants

View Source
const METATHINGS_COMPONENT_PREFIX = "mtc"

Variables

View Source
var (
	ErrUnaryCallTimeout           = errors.New("unary call timeout")
	ErrStreamCallConfigAckTimeout = errors.New("stream call config ack timeout")
	ErrStreamCallConfig           = errors.New("stream call config error")
	ErrUnexceptedResponse         = errors.New("unexpected response")
	ErrBadScheme                  = errors.New("bad scheme")
	ErrBadServiceEndpoint         = errors.New("bad service endpoint")
	ErrDefaultAddressRequired     = errors.New("default address required")
	ErrDeviceAddressRequired      = errors.New("device address required")
	ErrInvalidArguments           = errors.New("invalid arguments")
	ErrSubscribedSession          = errors.New("subscribed session")
	ErrUnsubscribedSession        = errors.New("unsubscribed session")
	ErrStartTimeout               = errors.New("start timeout")
)
View Source
var (
	MQTT_UPSTREAM   = "upstream"
	MQTT_DOWNSTREAM = "downstream"
)
View Source
var (
	ErrHandleUnimplemented = errors.New("handle unimplemented")
)
View Source
var (
	ErrUnknownModuleProxyDriver = errors.New("unknown module proxy driver")
)
View Source
var (
	ErrUnknownModuleServerAdapter = errors.New("unknown module server adapter")
)

Functions

func ToModule

func ToModule(v **Module) func(string, interface{}) error

Types

type Endpoint added in v1.0.0

type Endpoint struct {
	*url.URL
}

func ParseEndpoint added in v1.0.0

func ParseEndpoint(ep string) (*Endpoint, error)

func (*Endpoint) GetTransportProtocol added in v1.0.0

func (ep *Endpoint) GetTransportProtocol(defaults ...string) string

func (*Endpoint) IsMetathingsProtocol added in v1.0.0

func (ep *Endpoint) IsMetathingsProtocol() bool

type GrpcModuleProxy

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

func (*GrpcModuleProxy) Close added in v1.0.0

func (self *GrpcModuleProxy) Close() error

func (*GrpcModuleProxy) StreamCall

func (self *GrpcModuleProxy) StreamCall(ctx context.Context, method string, upstm ModuleProxyStream) error

func (*GrpcModuleProxy) UnaryCall

func (self *GrpcModuleProxy) UnaryCall(ctx context.Context, method string, value *any.Any) (*any.Any, error)

type GrpcModuleProxyFactory

type GrpcModuleProxyFactory struct{}

func (*GrpcModuleProxyFactory) NewModuleProxy

func (self *GrpcModuleProxyFactory) NewModuleProxy(args ...interface{}) (ModuleProxy, error)

type GrpcModuleServer

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

func (*GrpcModuleServer) Serve

func (s *GrpcModuleServer) Serve() error

func (*GrpcModuleServer) Stop

func (s *GrpcModuleServer) Stop()

type GrpcModuleServiceClientFactory

type GrpcModuleServiceClientFactory interface {
	NewModuleServiceClient(opts ...grpc.DialOption) (pb.ModuleServiceClient, client_helper.CloseFn, error)
}

func NewGrpcModuleServiceClientFactory

func NewGrpcModuleServiceClientFactory(addr string) GrpcModuleServiceClientFactory

type GrpcModuleServiceClientFactoryImpl

type GrpcModuleServiceClientFactoryImpl struct {
	Address string
}

func (*GrpcModuleServiceClientFactoryImpl) NewModuleServiceClient

type GrpcModuleWrapper

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

func NewGrpcModuleWrapper

func NewGrpcModuleWrapper(target interface{}, logger log.FieldLogger) *GrpcModuleWrapper

func (*GrpcModuleWrapper) StreamCall

func (self *GrpcModuleWrapper) StreamCall(upstm pb.ModuleService_StreamCallServer) error

func (*GrpcModuleWrapper) UnaryCall

type Kernel

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

func NewKernel

func NewKernel(opt *NewKernelOption) (*Kernel, error)

func (*Kernel) Config

func (k *Kernel) Config() *KernelConfig

func (*Kernel) Context

func (k *Kernel) Context() context.Context

func (*Kernel) GetObject

func (k *Kernel) GetObject(name string) (*deviced_pb.Object, error)

func (*Kernel) GetObjectContent

func (k *Kernel) GetObjectContent(name string) ([]byte, error)

func (*Kernel) Heartbeat

func (k *Kernel) Heartbeat() error

func (*Kernel) PutObject

func (k *Kernel) PutObject(name string, content io.Reader) error

func (*Kernel) PutObjects

func (k *Kernel) PutObjects(objects map[string]io.Reader) error

func (*Kernel) RemoveObject

func (k *Kernel) RemoveObject(name string) error

func (*Kernel) RemoveObjects

func (k *Kernel) RemoveObjects(names []string) error

func (*Kernel) RenameObject

func (k *Kernel) RenameObject(src, dst string) error

func (*Kernel) Show

func (k *Kernel) Show() (*deviced_pb.Module, error)

type KernelConfig

type KernelConfig struct {
	*viper.Viper
}

func NewKernelConfigFromText

func NewKernelConfigFromText(text string) (*KernelConfig, error)

func (*KernelConfig) Raw

func (kc *KernelConfig) Raw() *viper.Viper

func (*KernelConfig) Sub

func (kc *KernelConfig) Sub(key string) *KernelConfig

type Module

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

func NewModule

func NewModule(name string, target interface{}) (*Module, error)

func (*Module) GetObject

func (m *Module) GetObject(name string) (*deviced_pb.Object, error)

func (*Module) GetObjectContent

func (m *Module) GetObjectContent(name string) ([]byte, error)

func (*Module) HeartbeatLoop

func (m *Module) HeartbeatLoop()

func (*Module) Init

func (m *Module) Init() error

func (*Module) Kernel

func (m *Module) Kernel() *Kernel

func (*Module) Launch

func (m *Module) Launch() error

func (*Module) Logger

func (m *Module) Logger() log.FieldLogger

func (*Module) Name

func (m *Module) Name() string

func (*Module) PutObject

func (m *Module) PutObject(name string, content io.Reader) error

func (*Module) PutObjects

func (m *Module) PutObjects(objects map[string]io.Reader) error

func (*Module) RemoveObject

func (m *Module) RemoveObject(name string) error

func (*Module) RemoveObjects

func (m *Module) RemoveObjects(names []string) error

func (*Module) RenameObject

func (m *Module) RenameObject(src, dst string) error

func (*Module) Serve

func (m *Module) Serve() error

func (*Module) Stop

func (m *Module) Stop()

func (*Module) Target

func (m *Module) Target() interface{}

func (*Module) WithNamespace

func (m *Module) WithNamespace(name string) string

type ModuleOption

type ModuleOption struct {
	Config           string
	CredentialId     string
	CredentialSecret string
	Addresses        []string
}

type ModuleProxy

type ModuleProxy interface {
	UnaryCall(ctx context.Context, method string, req *any.Any) (*any.Any, error)
	StreamCall(ctx context.Context, method string, stm ModuleProxyStream) error
	Close() error
}

func NewModuleProxy

func NewModuleProxy(name string, args ...interface{}) (ModuleProxy, error)

type ModuleProxyFactory

type ModuleProxyFactory interface {
	NewModuleProxy(args ...interface{}) (ModuleProxy, error)
}

type ModuleProxyStream

type ModuleProxyStream interface {
	Send(*any.Any) error
	Recv() (*any.Any, error)
	grpc.ClientStream
}

type ModuleServer

type ModuleServer interface {
	Stop()
	Serve() error
}

func NewGrpcModuleServer

func NewGrpcModuleServer(m *Module) (ModuleServer, error)

func NewModuleServer

func NewModuleServer(name string, mdl *Module) (ModuleServer, error)

type ModuleServerFactory

type ModuleServerFactory func(*Module) (ModuleServer, error)

type ModuleServiceInitializer

type ModuleServiceInitializer interface {
	InitModuleService(*Module) error
}

type ModuleServiceLookuper

type ModuleServiceLookuper interface {
	LookupUnaryCall()
	LookupStreamCall()
}

type MqttModuleProxy added in v1.0.0

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

func (*MqttModuleProxy) Close added in v1.0.0

func (p *MqttModuleProxy) Close() error

func (*MqttModuleProxy) StreamCall added in v1.0.0

func (p *MqttModuleProxy) StreamCall(ctx context.Context, method string, upstm ModuleProxyStream) error

func (*MqttModuleProxy) UnaryCall added in v1.0.0

func (p *MqttModuleProxy) UnaryCall(ctx context.Context, method string, value *any.Any) (*any.Any, error)

type MqttModuleProxyFactory added in v1.0.0

type MqttModuleProxyFactory struct{}

func (*MqttModuleProxyFactory) NewModuleProxy added in v1.0.0

func (f *MqttModuleProxyFactory) NewModuleProxy(args ...interface{}) (ModuleProxy, error)

type MqttModuleProxyOption added in v1.0.0

type MqttModuleProxyOption struct {
	Module struct {
		Id string
	}
	Session struct {
		Id int64
	}
	Config struct {
		UnaryCallTimeout           time.Duration
		StreamCallConfigAckTimeout time.Duration
		MQTTConnectTimeout         time.Duration
		MQTTDisconnectTimeout      time.Duration
	}
	MQTT struct {
		Address  string
		Username string
		Password string
		ClientId string
		QoS      byte
	}
}

type NewKernelOption

type NewKernelOption struct {
	Credential struct {
		Id     string
		Secret string
	}
	ServiceEndpoints map[string]string
	ConfigText       string
}

Jump to

Keyboard shortcuts

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