nwconnector

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// TopicNetworkTpl 创建网络连接
	//
	//Deprecated
	TopicNetworkTpl = "oss.network.%s" // schedule/network/{network_type}

	// TopicHeartbeatTpl 网络心跳
	//
	// Deprecated
	TopicHeartbeatTpl = "oss.network.heartbeat" // oss.network.heartbeat
)
View Source
const (
	BridgeQueueMqtt    = "oss.bridge.mqtt"
	BridgeQueueLoraWAN = "oss.bridge.lorawan"
	BridgeQueueTree    = "oss.bridge.tree"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AzureIotHubConfig added in v0.6.1

type AzureIotHubConfig struct {
	Host            string `json:"host,omitempty"`
	DeviceId        string `json:"deviceId,omitempty"`
	SharedAccessKey string `json:"sharedAccessKey,omitempty"`
}

AzureIotHubConfig azure iot_hub rest api

func (AzureIotHubConfig) Build added in v0.6.1

func (a AzureIotHubConfig) Build() string

type Connector

type Connector interface {
	// Connect 连接
	Connect() error
	// Disconnect 销毁连接
	Disconnect() error
	Ping()
}

type ConnectorPool

type ConnectorPool interface {
	Add(id string, c Connector)
	Remove(id string)
	Subscribe(event NetworkEvent)
	NetworkType() NetworkType
}

ConnectorPool

连接池
规则:一个网络ID维持一个连接实例. 同一网络ID如需同时维持多个实例,需要通过启动多个应用实例实现
负责管理连接,但不负责创建连接

type EventType

type EventType int

EventType 事件类型

const (
	// EventCreate 创建连接。controller->bridge, bridge创建一个新的连接
	EventCreate EventType = 1
	// EventDestroy 销毁连接。controller->bridge, bridge销毁一个已存在的连接
	EventDestroy EventType = 2
	// EventHeartbeat 心跳。bridge->controller, controller在心跳超时后,判定连接失效
	EventHeartbeat EventType = 3
)

网络事件

type LorawanMqttConfig added in v0.6.1

type LorawanMqttConfig struct {
	Host     string `json:"host,omitempty"`
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
	ClientId string `json:"clientId,omitempty"`
	LorawanOssConfig
}

LorawanMqttConfig 使用mqtt协议连接lorawan服务器

type LorawanOssConfig added in v0.6.3

type LorawanOssConfig struct {
	OssHost     string `json:"ossHost,omitempty"`
	OssUser     string `json:"ossUser,omitempty"`
	OssPassword string `json:"ossPassword,omitempty"`
}

type LorawanRestConfig added in v0.6.1

type LorawanRestConfig struct {
	Host     string `json:"host,omitempty"`
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
}

LorawanRestConfig 使用rest协议连接lorawan服务器

type MqttConfig added in v0.6.1

type MqttConfig struct {
	Host     string `json:"host,omitempty"`
	Username string `json:"username,omitempty"`
	Password string `json:"password,omitempty"`
	ClientId string `json:"clientId,omitempty"` // 如果不设置client id,需要支持随机client id
}

MqttConfig 连接MQTT服务器的配置

type NetworkConfig added in v0.3.0

type NetworkConfig struct {
	NetworkId         string      `json:"network_id,omitempty"`          // 编号
	NetworkInstanceId string      `json:"network_instance_id,omitempty"` // 连接实例编号
	ConnectInfo       string      `json:"connect_info,omitempty"`        // 连接配置(json->base64格式)
	ExpireTime        int64       `json:"expire_time,omitempty"`         // 自定义网络超时时间,特定的网络超时时间
	NetworkType       NetworkType `json:"network_type,omitempty"`
}

NetworkConfig 网络配置

type NetworkEvent

type NetworkEvent struct {
	EventType EventType `json:"event_type,omitempty"`
	NetworkConfig
}

type NetworkType added in v0.1.5

type NetworkType string

NetworkType 网络类型

const (
	Mqtt    NetworkType = "MQTT"
	Lorawan NetworkType = "LORAWAN"
	Tree    NetworkType = "TREE"
)

type Schedule

type Schedule interface {
	// Connect 创建连接
	Connect(networkStruct NetworkConfig)
	// DisConnect 销毁连接
	DisConnect(networkStruct NetworkConfig)
	// OnPing 收到Ping(更新timeout)
	OnPing(func(networkStruct NetworkConfig))
}

Jump to

Keyboard shortcuts

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