common_type

package
v0.0.0-...-f13fc7a Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusOK                    = http.StatusOK
	UnknownError                = 11000 // 任何时候都不应该主动使用
	MsgTimeOut                  = 11001
	SocketListenOrDialFailure   = 11002
	TargetEndpointNotFound      = 11003
	ProtoUnmarshalFailure       = 11004
	ProtoMarshalFailure         = 11005
	DbSelectFailure             = 11006
	DbExecFailure               = 11007
	DbSqlSyntaxErr              = 11008
	CreateFileFailure           = 11009
	RenameFileFailure           = 11010
	RemoveFileFailure           = 11011
	IsExistFileFailure          = 11012
	CopyFileFailure             = 11013
	ListFileFailure             = 11014
	IsDirFailure                = 11015
	ReadFailure                 = 11016
	ReadLinesFailure            = 11017
	WriteBytesFailure           = 11018
	AppendBytesFailure          = 11019
	WriteStringsFailure         = 11020
	AppendStringsFailure        = 11021
	ZipFailure                  = 11022
	UnZipFailure                = 11023
	GzFailure                   = 11024
	UnGzFailure                 = 11025
	HashFailure                 = 11026
	MakeDirFailure              = 11027
	CallPluginHttpFailure       = 11028
	CallPluginConfigFailure     = 11029
	OnEnableFailure             = 11030
	OnDisEnableFailure          = 11031
	OnUpgradeFailure            = 11032
	OnCheckCompatibilityFailure = 11033
	OnCheckStateFailure         = 11034
	OnHeartbeatFailure          = 11035
	OnPluginHttpFailure         = 11036
	AsyncFetchFailure           = 11037
	GetInstanceFailure          = 11038
	CallMainSystemAPIFailure    = 11039
	DbErrorFailure              = 11040
	FileNotFoundFailure         = 11041
	CallSysAPIFailure           = 11042
	OutgoingFailure             = 11043
	SysDbImportSqlFailure       = 11044
	DataBaseNameFailure         = 11045
	NotifyEventFailure          = 11046
	CallAbilityFailure          = 11047
	UnmarshalFailure            = 11048
	AddGroupFieldFailure        = 11051
	UpdateFieldOptionFailure    = 11052
	OnInstallFailure            = 11053
	OnUnInstallFailure          = 11054
	LocalDevelopErr             = 11055
	EndpointReceiveErr          = 11056
	EndpointSendErr             = 11057
	EndpointIdentifyErr         = 11058
	HostNotFoundErr             = 11059
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APICore

type APICore interface {
	Fetch(*HttpRequest) *HttpResponse
}

type Ability

type Ability interface {
	Call(kind string, req []byte) ([]byte, PluginError)
}

type AbilityRequest

type AbilityRequest struct {
	ID   string `json:"id"`
	Type string `json:"type"`
	Func string `json:"func"`
	Args []byte `json:"args"`
}

type AbilityResponse

type AbilityResponse struct {
	Data []byte      `json:"data"`
	Err  PluginError `json:"err"`
}

type AsyncInvokeCallbackParams

type AsyncInvokeCallbackParams func(PluginError)

type ColumnDesc

type ColumnDesc struct {
	Index int64
	Name  string
	Type  string
}

type DBCallBack

type DBCallBack func([]*RawData, []*ColumnDesc, PluginError)

type EventPublisher

type EventPublisher interface {
	Subscribe(condition []string) PluginError                                       // 不支持通配符, ex: project.task.create
	SubscribeWithFilter(condition []string, filter map[string][]string) PluginError // 支持过滤条件, ex: filter: project_uuid_in:[""]
	Unsubscribe(condition []string) PluginError                                     // 支持通配符
}

type HeaderVal

type HeaderVal struct {
	Val []string
}

type HostBootInfo

type HostBootInfo struct {
	ID      string
	Name    string
	Version string
}

type HostBootStatus

type HostBootStatus int
const (
	HostBootStatusNormal HostBootStatus = 1
	HostBootStatusDrift  HostBootStatus = 2
)

type HostInfo

type HostInfo struct {
	ID               string
	Name             string
	Version          string
	MinSystemVersion string
	Language         string
	LanguageVersion  string
	RunningPlugins   map[string]IInstanceDescription
	SupportPlugins   map[string]IInstanceDescription
}

type HostStatus

type HostStatus int
const (
	HostStatusNormal HostStatus = 1
	HostStatusDrift  HostStatus = 2
)

type HttpContext

type HttpContext struct {
	Params   map[string]string
	Request  *HttpRequest
	Response *HttpResponse
}

type HttpRequest

type HttpRequest struct {
	Method   string
	QueryMap map[string]string
	Url      string
	Path     string
	Headers  map[string][]string
	Body     []byte
	Root     bool
}

type HttpResponse

type HttpResponse struct {
	Err        PluginError
	Headers    map[string][]string
	Body       []byte
	StatusCode int
}

type IHost

type IHost interface {
	//Store()
	GetInfo() HostInfo
	GetStatus() HostStatus
}

type IHostBoot

type IHostBoot interface {
	GetInfo() HostBootInfo
	GetStatus() HostBootStatus
}

type IInstanceDescription

type IInstanceDescription interface {
	PluginDescription() IPluginDescriptor
	InstanceID() string
}

type IPlugin

type IPlugin interface {
	// 程序实现
	Assign(pid IInstanceDescription, resources IResources) PluginError
	GetPluginDescription() IInstanceDescription

	// 业务动作
	Enable(LifeCycleRequest) PluginError
	Disable(LifeCycleRequest) PluginError
	Install(LifeCycleRequest) PluginError
	UnInstall(LifeCycleRequest) PluginError
	Upgrade(IVersion, LifeCycleRequest) PluginError
	CheckState() PluginError
	CheckCompatibility() PluginError

	// 事件相关
	OnEvent(eventType string, payload []byte) PluginError

	// 配置修改
	OnConfigChange(configKey string, originValue, newValue []string) PluginError

	// 外部请求
	OnExternalHttpRequest(request *HttpRequest) *HttpResponse
}

type IPluginDescriptor

type IPluginDescriptor interface {
	ApplicationID() string
	Name() string
	Language() string
	LanguageVersion() IVersion
	ApplicationVersion() IVersion
	HostVersion() IVersion
	MinSystemVersion() IVersion
}

type IResources

type IResources interface {
	GetLogger() PluginLogger
	GetWorkspace() Workspace
	GetLocalDB() LocalDB
	GetEventPublisher() EventPublisher
	GetSysDB() SysDB
	GetAPICore() APICore
	GetOutDoor() Network
	GetAbility() Ability
}

type IVersion

type IVersion interface {
	Major() int
	Minor() int
	Revision() int
	VersionString() string
	Relationship(IVersion) VersionTime
}

func NewVersion

func NewVersion(major, minor, revision int) IVersion

type LifeCycleRequest

type LifeCycleRequest struct {
	Headers map[string]*HeaderVal
}

type LocalDB

type LocalDB interface {
	Select(sql string) ([]*RawData, []*ColumnDesc, PluginError)
	AsyncSelect(sql string, callback DBCallBack)
	// Unmarshal eg:
	//	type User struct {
	//		UUID string `orm:"uuid"`
	//		Name string `orm:"name"`
	//	}
	//	users := make([]*User, 0)
	//	err = Unmarshal(rawData, colDesc, &users)
	Unmarshal(rawData []*RawData, columnDesc []*ColumnDesc, v interface{}) PluginError
	Exec(sql string) PluginError
	ImportSQL(sqlFilePath string) PluginError
}

type MockHost

type MockHost struct {
	Info   HostInfo
	Status HostStatus
}

func (*MockHost) GetInfo

func (h *MockHost) GetInfo() HostInfo

func (*MockHost) GetStatus

func (h *MockHost) GetStatus() HostStatus

type MockHostBoot

type MockHostBoot struct {
	Info   HostBootInfo
	Status HostBootStatus
}

func (*MockHostBoot) GetInfo

func (b *MockHostBoot) GetInfo() HostBootInfo

func (*MockHostBoot) GetStatus

func (b *MockHostBoot) GetStatus() HostBootStatus

type MockInstanceDesc

type MockInstanceDesc struct {
	PluginInstanceID string
	PluginDescriptor *MockPluginDescriptor
}

func (*MockInstanceDesc) InstanceID

func (i *MockInstanceDesc) InstanceID() string

func (*MockInstanceDesc) PluginDescription

func (i *MockInstanceDesc) PluginDescription() IPluginDescriptor

type MockPluginDescriptor

type MockPluginDescriptor struct {
	AppID      string
	PluginName string
	Lang       string
	LangVer    string
	AppVer     string
	HostVer    string
	MinSysVer  string
}

func (*MockPluginDescriptor) ApplicationID

func (i *MockPluginDescriptor) ApplicationID() string

func (*MockPluginDescriptor) ApplicationVersion

func (i *MockPluginDescriptor) ApplicationVersion() IVersion

func (*MockPluginDescriptor) HostVersion

func (i *MockPluginDescriptor) HostVersion() IVersion

func (*MockPluginDescriptor) Language

func (i *MockPluginDescriptor) Language() string

func (*MockPluginDescriptor) LanguageVersion

func (i *MockPluginDescriptor) LanguageVersion() IVersion

func (*MockPluginDescriptor) MinSystemVersion

func (i *MockPluginDescriptor) MinSystemVersion() IVersion

func (*MockPluginDescriptor) Name

func (i *MockPluginDescriptor) Name() string

type Network

type Network interface {
	Fetch(*HttpRequest) *HttpResponse

	AsyncFetch(*HttpRequest, NetworkCallBack)
}

type NetworkCallBack

type NetworkCallBack func(*HttpResponse, PluginError)

type PError

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

func (*PError) Code

func (pe *PError) Code() int

func (*PError) Error

func (pe *PError) Error() string

func (*PError) Msg

func (pe *PError) Msg() string

type PluginError

type PluginError interface {
	Code() int
	Error() string
	Msg() string
}

func NewPluginError

func NewPluginError(code int, msg string) PluginError

type PluginFactory

type PluginFactory interface {
	GetPlugin() IPlugin
}

type PluginLogger

type PluginLogger interface {
	Trace(string)
	Info(string)
	Warn(string)
	Error(string)
}

type RawData

type RawData struct {
	Cell [][]byte
}

type SysDB

type SysDB interface {
	Select(db, sql string) ([]*RawData, []*ColumnDesc, PluginError)
	AsyncSelect(db, sql string, callback DBCallBack)
	Exec(db, sql string) PluginError
	// Unmarshal eg:
	//	type User struct {
	//		UUID string `orm:"uuid"`
	//		Name string `orm:"name"`
	//	}
	//	users := make([]*User, 0)
	//	err = Unmarshal(rawData, colDesc, &users)
	Unmarshal(rawData []*RawData, columnDesc []*ColumnDesc, v interface{}) PluginError
}

type Version

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

func ParseVersionString

func ParseVersionString(vs string) (*Version, error)

func (*Version) GetVersion

func (v *Version) GetVersion() IVersion

func (*Version) Major

func (v *Version) Major() int

func (*Version) Minor

func (v *Version) Minor() int

func (*Version) Relationship

func (v *Version) Relationship(t IVersion) VersionTime

func (*Version) Revision

func (v *Version) Revision() int

func (*Version) VersionString

func (v *Version) VersionString() string

type VersionTime

type VersionTime int
const (
	Earlier VersionTime = -1
	Same    VersionTime = 0
	Later   VersionTime = 1
)

func (*VersionTime) ToString

func (vt *VersionTime) ToString() string

Jump to

Keyboard shortcuts

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