91 lines
4.0 KiB
Plaintext
91 lines
4.0 KiB
Plaintext
список функций device_status.go (Проверяет статус устройства):
|
|
func NewDeviceStatus(redisClient *redis.Client) *DeviceStatus
|
|
func (ds *DeviceStatus) GetOnline(ctx context.Context, devID string) (string, error)
|
|
func (ds *DeviceStatus) SetOnline(ctx context.Context, devID string) error
|
|
|
|
Список функций и структур STOMPlib.go (Реализует подключение по STOMP):
|
|
type STOMPlib struct {
|
|
client *stomp.Conn
|
|
waitMessages map[string]*time.Timer
|
|
state bool
|
|
brokerURL string
|
|
}
|
|
func NewSTOMPlib() *STOMPlib
|
|
func (s *STOMPlib) SendMessage(topic, id, message string)
|
|
|
|
Список функций и структур clickhouse.go (БД Clickhouse):
|
|
type Clickhouse struct {
|
|
DB *sql.DB
|
|
TablesQueues map[string][]interface{}
|
|
NeedCountForTable map[string]int
|
|
TableTemplate map[string]string
|
|
}
|
|
func NewClickhouse() *Clickhouse
|
|
func (ch *Clickhouse) InitDB() error
|
|
func (ch *Clickhouse) Insert(table string, data interface{}) error
|
|
func (ch *Clickhouse) FlushQueue(table string) error
|
|
|
|
Список функций и структур mysql.go (БД Mysql):
|
|
type Database struct {
|
|
db *sql.DB
|
|
}
|
|
func NewSQLDatabase() *Database
|
|
func (d *Database) Query(query string) (*sql.Rows, error)
|
|
func (d *Database) Close()
|
|
|
|
Список функций и структур logger.go (Aka "LoggerAndExceptionHandler", Логгер):
|
|
type LoggerAndExceptionHandler struct {
|
|
sentryEnabled bool
|
|
}
|
|
func NewLoggerAndExceptionHandler() *LoggerAndExceptionHandler
|
|
func (l *LoggerAndExceptionHandler) [Info || Debug || Fatal || Error || Critical || Warning || Log] (message string)
|
|
|
|
Список функций и структур request_controller.go (Контроллер данных):
|
|
type RequestController struct {
|
|
MySQL *databases.Database
|
|
LoggerAndExceptionHandler *logger.LoggerAndExceptionHandler
|
|
Clickhouse *databases.Clickhouse
|
|
STOMP *STOMPlib
|
|
deviceDebugList []string
|
|
}
|
|
func NewRequestController() *RequestController
|
|
func (rc *RequestController) WriteLog(devID string, data interface{}, ts time.Time)
|
|
func (rc *RequestController) getDebugDeviceList() error
|
|
func (rc *RequestController) getDebugDeviceListPeriodically()
|
|
func (rc *RequestController) CheckDeviceDebugMode(devID string) bool
|
|
|
|
Список функций и структур device_registry.go (Реестр устройств):
|
|
type Device struct { #$fakedata
|
|
id string
|
|
name string
|
|
mid string
|
|
device_id string
|
|
ts_sync int64
|
|
}
|
|
type DeviceUptime struct { #$fakedata
|
|
id string
|
|
device_id string
|
|
status int
|
|
}
|
|
type DeviceRegistry struct {
|
|
DeviceRegistry map[string]Device
|
|
DeviceUptimeRegistry map[string]DeviceUptime
|
|
RequestController *RequestController
|
|
OnlineDevices []string
|
|
TempBeforeUpdateTSSYNC []string
|
|
}
|
|
func NewDeviceRegistry(rc *RequestController) *DeviceRegistry
|
|
func (dr *DeviceRegistry) initializeRegistry()
|
|
func (dr *DeviceRegistry) FindDevice(mid string) Device
|
|
func (dr *DeviceRegistry) CheckOnline(device Device)
|
|
func (dr *DeviceRegistry) WriteMM_AgentData(deviceID string, uptime string, queueSize string)
|
|
func (dr *DeviceRegistry) UpdateDeviceTsSync(deviceID string)
|
|
func (dr *DeviceRegistry) MarkDeviceOnline(deviceList []string)
|
|
func (dr *DeviceRegistry) MarkDeviceOffline(mid string)
|
|
func (dr *DeviceRegistry) FindUptime(id string) (DeviceUptime, error)
|
|
func (dr *DeviceRegistry) GlobalUpdateTsSync()
|
|
func (dr *DeviceRegistry) CheckDeviceOnline(deviceID string) bool
|
|
func contains(arr []string, val string) bool
|
|
|
|
|
|
// TODO Multilinks |