rule

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KindMqtt       kind = "mqtt"
	KindMqttCMFT   kind = "mqtt-cmft"
	KinkHTTP       kind = "http"
	KindHTTPServer kind = "http-server"
)

All kinds

Variables

This section is empty.

Functions

func NewClient

func NewClient(ctx context.Context, clientDetail *ClientDetail) (s client.Client, err error)

func RegularPubTopic added in v2.4.0

func RegularPubTopic(source, actual, pub, path string) string

func Wrapper added in v2.4.0

func Wrapper(handler HandlerFunc) func(ctx *routing.Context) error

Types

type ClientDetail added in v2.4.0

type ClientDetail struct {
	Name         string
	Subscription []mqtt.QOSTopic
	Info         ClientInfo
}

type ClientInfo

type ClientInfo struct {
	Name  string                 `yaml:"name" json:"name" validate:"nonzero"`
	Kind  kind                   `yaml:"kind" json:"kind" validate:"nonzero"`
	Value map[string]interface{} `yaml:",inline" json:",inline"`
}

ClientInfo client info

func (*ClientInfo) Parse

func (v *ClientInfo) Parse(in interface{}) error

Parse parse to get real config

type ClientRef

type ClientRef struct {
	Client string `yaml:"client" json:"client" default:"baetyl-broker"`
	QOS    int    `yaml:"qos" json:"qos" default:"0"`
	Topic  string `yaml:"topic" json:"topic" default:""`
	Path   string `yaml:"path" json:"path" default:""`
	Method string `yaml:"method" json:"method" default:"POST"`
}

ClientRef ref to client

type ClientSet added in v2.4.0

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

func NewRulers

func NewRulers(ctx context.Context, cfg Config, functionClient *http.Client) (*ClientSet, error)

func (*ClientSet) Close added in v2.4.0

func (l *ClientSet) Close()

type Config

type Config struct {
	Clients []ClientInfo `yaml:"clients" json:"clients"`
	Rules   []RuleInfo   `yaml:"rules" json:"rules"`
}

Config config of rule

type FunctionInfo

type FunctionInfo struct {
	Name string `yaml:"name" json:"name" validate:"nonzero"`
}

FunctionInfo function info

type HTTPServer added in v2.4.0

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

func NewHTTPServer added in v2.4.0

func NewHTTPServer(info ClientInfo, functionCli *http.Client) (*HTTPServer, error)

func (*HTTPServer) Close added in v2.4.0

func (h *HTTPServer) Close()

func (*HTTPServer) HandleHTTPRule added in v2.4.0

func (h *HTTPServer) HandleHTTPRule(ctx *routing.Context) (interface{}, error)

func (*HTTPServer) Start added in v2.4.0

func (h *HTTPServer) Start()

type HandlerFunc added in v2.4.0

type HandlerFunc func(ctx *routing.Context) (interface{}, error)

type MqttCMFTInfo added in v2.4.0

type MqttCMFTInfo struct {
	Address      string `yaml:"address" json:"address" validate:"nonzero"`
	ProductId    string `yaml:"productId" json:"productId" validate:"nonzero"`
	DeviceId     string `yaml:"deviceId" json:"deviceId" validate:"nonzero"`
	DeviceSecret string `yaml:"deviceSecret" json:"deviceSecret" validate:"nonzero"`
}

type RuleInfo

type RuleInfo struct {
	Name     string        `yaml:"name" json:"name" validate:"nonzero"`
	Source   *ClientRef    `yaml:"source" json:"source" validate:"nonzero"`
	Target   *ClientRef    `yaml:"target" json:"target"`
	Function *FunctionInfo `yaml:"function" json:"function"`
}

RuleInfo rule info

type ServerConfig added in v2.4.0

type ServerConfig struct {
	Port int32 `yaml:"port" json:"port"`
	utils.Certificate
}

type SingleClient added in v2.4.0

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

func (*SingleClient) Start added in v2.4.0

func (l *SingleClient) Start(clients map[string]*SingleClient, functionClient *http.Client) error

Jump to

Keyboard shortcuts

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