dao

package
v0.0.0-...-cba6ad5 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeMessageRule uint8 = iota + 1
	TypeTimeseriesRule
)

Const for Rule's Type

View Source
const (
	StatusNotRunning uint8 = iota
	StatusRunning
)

Const for Rule's Status

View Source
const (
	TargetTypeKafka = iota + 1
	TargetTypeObjectStorage
)

The field for Target type

View Source
const (
	KeyRawData   = "rawData"
	KeyTeleMetry = "telemetry"
)

The key of the entity properties

View Source
const (
	RuleTypeMessage    = 1
	RuleTypeTimeseries = 2
)

rule type.

View Source
const SubscribeService string = "http://localhost:3500/v1.0/invoke/keel/method/apis/core-broker/v1/subscribe/%d"
View Source
const SubscriptionIDFormat = "%s_%d_%s"

Variables

This section is empty.

Functions

func CoreClient

func CoreClient() *core.Client

func DB

func DB() *gorm.DB

func GenUniqueKey

func GenUniqueKey(ruleID uint, entityID string) string

func GetRedis

func GetRedis() *redis.Client

func InitRedis

func InitRedis(addr, password string, db int)

func Setup

func Setup() error

func UpdateEntityRuleInfo

func UpdateEntityRuleInfo(entityID, ruleinfo string, c choice) error

Types

type Rule

type Rule struct {
	// gorm.Model
	ID          uint `gorm:"primarykey"`
	CreatedAt   time.Time
	UpdatedAt   time.Time
	UserID      string `gorm:"index;uniqueIndex:user_rule"`
	TenantID    string
	ModelID     string
	ModelName   string
	SubID       uint
	SubEndpoint string
	Name        string `gorm:"not null;size:255;uniqueIndex:user_rule"`
	Status      uint8  `gorm:"default:0;comment:'0:not_running,1:running'"`
	Desc        string
	Type        uint8 `gorm:"not null;index;comment:'1:message;2:timeseries'"`
	SelectExpr  string
	WhereExpr   string
}

func (*Rule) BeforeCreate

func (r *Rule) BeforeCreate(tx *gorm.DB) (err error)

func (*Rule) BeforeDelete

func (r *Rule) BeforeDelete(tx *gorm.DB) (err error)

func (*Rule) Exists

func (r *Rule) Exists() (bool, error)

func (*Rule) InitMetrics

func (r *Rule) InitMetrics()

func (*Rule) SelectFirst

func (r *Rule) SelectFirst() *gorm.DB

func (*Rule) Subscribe

func (r *Rule) Subscribe(id uint, auth string) error

func (*Rule) SwitchStatus

func (r *Rule) SwitchStatus() error

func (*Rule) Unsubscribe

func (r *Rule) Unsubscribe() error

func (*Rule) UpdateTenantID

func (s *Rule) UpdateTenantID(userID, tenantID string)

type RuleEntities

type RuleEntities struct {
	UniqueKey string `gorm:"uniqueIndex;size:255"`
	RuleID    uint
	EntityID  string

	Rule Rule
}

func (*RuleEntities) BeforeCreate

func (e *RuleEntities) BeforeCreate(tx *gorm.DB) error

func (*RuleEntities) BeforeDelete

func (e *RuleEntities) BeforeDelete(tx *gorm.DB) error

func (*RuleEntities) Count

func (e *RuleEntities) Count(tx *gorm.DB) (c int64, err error)

func (*RuleEntities) Find

func (e *RuleEntities) Find(tx *gorm.DB) []RuleEntities

func (*RuleEntities) FindEntityIDS

func (e *RuleEntities) FindEntityIDS() []string

type Target

type Target struct {
	ID     uint  `gorm:"primaryKey"`
	Type   uint8 `gorm:"not null;index;comment:'1:kafka;2:object-storage'"`
	Host   string
	Value  string
	Ext    *string `gorm:"type:json;null"`
	RuleID uint

	Status       string `gorm:"column:status"`
	ConfigStatus bool   `gorm:"column:config_status"`
	//	Configuration   map[string]interface{} `gorm:"column:configuration"`
	SinkType        string `gorm:"column:sink_type"`
	SinkId          string `gorm:"column:sink_id"`
	ErrorActionFlag bool   `gorm:"column:error_action_flag"`
	CreateTime      int64  `gorm:"column:create_time"`
	UpdateTime      int64  `gorm:"column:update_time"`
	Rule            Rule
}

func (*Target) AfterCreate

func (t *Target) AfterCreate(tx *gorm.DB) (err error)

func (*Target) Create

func (t *Target) Create() error

func (*Target) Delete

func (t *Target) Delete() error

func (*Target) Find

func (t *Target) Find() error

func (*Target) FindAndAuth

func (t *Target) FindAndAuth(userID string) error

func (*Target) Update

func (t *Target) Update() (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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