camStatics

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	B  uint64 = 1
	KB        = 1024 * B
	MB        = 1024 * KB
	GB        = 1024 * MB
	TB        = 1024 * GB
)
View Source
const (
	LogLevelTrace   LogLevel = 1                                                                                           // trace log
	LogLevelDebug            = LogLevelTrace << 1                                                                          // debug log
	LogLevelInfo             = LogLevelDebug << 1                                                                          // info log
	LogLevelWarn             = LogLevelInfo << 1                                                                           // warning log
	LogLevelError            = LogLevelWarn << 1                                                                           // error log
	LogLevelFatal            = LogLevelError << 1                                                                          // fatal log
	LogLevelNone             = 0                                                                                           // none
	LogLevelSuggest          = LogLevelInfo | LogLevelWarn | LogLevelError | LogLevelFatal                                 // suggest this level to write file
	LogLevelAll              = LogLevelTrace | LogLevelDebug | LogLevelInfo | LogLevelWarn | LogLevelError | LogLevelFatal // all
)

LogComponent

View Source
const (
	ModeInterface ValidMode = 1
	ModeTag                 = ModeInterface << 1
	ModeBoth                = ModeInterface | ModeTag
)

ValidationComponent

View Source
const (
	DatabaseDriverMysql = "mysql"
)

DatabaseComponent

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConfigInterface

type AppConfigInterface interface {
}

app config interface

type ApplicationInterface

type ApplicationInterface interface {
	// get Component instance by reflect
	GetComponent(v ComponentInterface) ComponentInterface
	// get Component instance by component name
	GetComponentByName(name string) ComponentInterface
	// get default db component's interface
	GetDB() DatabaseComponentInterface
	// run application
	Run()
	// stop application
	Stop()
	// add migration struct
	AddMigration(m MigrationInterface)
	// log trace
	Trace(title string, content string)
	// log debug
	Debug(title string, content string)
	// log info
	Info(title string, content string)
	// log warn
	Warn(title string, content string)
	// log error
	Error(title string, content string)
	// log fatal
	Fatal(title string, content string)
	// Add config
	AddConfig(config AppConfigInterface)
	// get value form .evn file
	GetEvn(key string) string
	// get params form camAppConfig.Config.Params
	GetParam(key string) interface{}
	// get migrate dict
	GetMigrateDict() map[string]MigrationInterface
	// get cache component
	GetCache() CacheComponentInterface
	// get mail component
	GetMail() MailComponentInterface
	// valid struct.
	Valid(v interface{}) (firstErr error, errDict map[string][]error)
	// Get grpc client conn
	// name: Component name
	GetGrpcClientConn(name string) *grpc.ClientConn
	// Before app init
	BeforeInit(handler func())
	// After app init
	AfterInit(handler func())
	// Before app start
	BeforeStart(handler func())
	// After app start
	AfterStart(handler func())
	// Before app stop
	BeforeStop(handler func())
	// After app start
	AfterStop(handler func())
}

application interface NODE: Provides interface function to the module inner framework

type ApplicationStatus

type ApplicationStatus int

app status

const (
	AppStatusBeforeInit ApplicationStatus = iota
	AppStatusBeforeStart
	AppStatusAfterStart
	AppStatusBeforeStop
	AppStatusAfterStop
)

type CacheComponentInterface

type CacheComponentInterface interface {
	// set cache storage default duration
	Set(key string, value interface{}) error
	// set cache storage custom duration
	SetDuration(key string, value interface{}, duration time.Duration) error
	// whether the key exists
	Exists(key string) bool
	// get value by key
	Get(key string) interface{}
	// delete cache
	Del(keys ...string) error
	// delete all cache
	Flush() error
}

cache component interface

type CamModuleType

type CamModuleType int

CamModule type

type ComponentConfigInterface

type ComponentConfigInterface interface {
	// new component
	NewComponent() ComponentInterface
	// get recover handler
	GetRecoverHandler() RecoverHandler
}

component config interface

type ComponentInterface

type ComponentInterface interface {
	// init
	Init(configInterface ComponentConfigInterface)
	// start
	Start()
	// stop
	Stop()
	// set app instance
	SetApp(app ApplicationInterface)
}

Component interface

type ConsoleComponentInterface

type ConsoleComponentInterface interface {
	// get database dir
	GetDatabaseDir() string
	// get xorm template dir
	GetXormTemplateDir() string
}

console component interface

type ContextInterface

type ContextInterface interface {
	// set session
	SetSession(session SessionInterface)
	// get session
	GetSession() SessionInterface
	// Write returned data
	Write(res []byte)
	// Read returned data
	Read() []byte
	// Set RecoverInterface. As a error panic by last handle route of handler
	SetRecover(rec RecoverInterface)
	// Get RecoverInterface
	GetRecover() RecoverInterface
	// Set route
	SetRoute(route string)
	// Get route
	GetRoute() string
}

context interface

type ControllerActionInterface

type ControllerActionInterface interface {
	// controller route
	Route() string
	// call action
	Call()
}

controller action interface

type ControllerInterface

type ControllerInterface interface {
	// init
	Init()
	// before action
	BeforeAction(action ControllerActionInterface) bool
	// after action
	AfterAction(action ControllerActionInterface, response []byte) []byte
	// set context
	SetContext(context ContextInterface)
	// get context
	GetContext() ContextInterface
	// set values.
	// it will replace the original values
	SetValues(values map[string]interface{})
	// get default action
	GetDefaultActionName() string
}

controller interface

type DatabaseComponentInterface

type DatabaseComponentInterface interface {
	// get data source name.
	// [username[:password]@][protocol[(address)]]/dbname[?param1=value1&...&paramN=valueN]
	GetDSN() string
	// get engine
	GetEngine() *xorm.Engine
	// get xorm session
	NewSession() *xorm.Session
}

database component interface

type GRpcComponentInterface

type GRpcComponentInterface interface {
	// get client conn
	Conn() *grpc.ClientConn
}

grpc component interface

type GRpcLoadBalancingLogic

type GRpcLoadBalancingLogic int

load balancing login

const (
	// Execute in sequence
	GRpcLoadBalancingLogicSequence GRpcLoadBalancingLogic = 1
)

type GrpcClientComponentInterface

type GrpcClientComponentInterface interface {
	GetConn() *grpc.ClientConn
}

type HttpContextInterface

type HttpContextInterface interface {
	ContextInterface
	SetHttpResponseWriter(responseWriter http.ResponseWriter)
	GetHttpResponseWriter() http.ResponseWriter
	SetHttpRequest(request *http.Request)
	GetHttpRequest() *http.Request
	CloseHandler(handler func())
	GetCookie(name string) *http.Cookie
	SetCookie(cookie *http.Cookie)
	DelCookie(name string)
	SetCookieValue(name string, value string)
	GetCookieValue(name string) string
	Close()
}

http context

type HttpRouteHandler

type HttpRouteHandler func(responseWriter http.ResponseWriter, request *http.Request)

http custom route handler

type LogLevel

type LogLevel uint8

log level

type MailComponentInterface

type MailComponentInterface interface {
	Send(subject string, body string, to ...string) error
}

mail component interface

type MessageParseHandler

type MessageParseHandler func(message []byte) (controllerName string, actionName string, values map[string]interface{})

message parse handler. it can read route and values info form the message

type MiddlewareInterface

type MiddlewareInterface interface {
	// call when route has middleware
	Handler(ctx ContextInterface, next NextHandler) []byte
}

middleware interface

type MigrationInterface

type MigrationInterface interface {
	// update migration
	Up()
	// recall migration
	Down()
	// get up sql list
	GetSqlList() []string
}

migration interface

type MysqlColumnBuilderInterface

type MysqlColumnBuilderInterface interface {
	Unsigned() MysqlColumnBuilderInterface
	NotNull() MysqlColumnBuilderInterface
	Null() MysqlColumnBuilderInterface
	Default(value interface{}) MysqlColumnBuilderInterface
	AutoIncrement() MysqlColumnBuilderInterface
	Comment(comment string) MysqlColumnBuilderInterface
	After(name string) MysqlColumnBuilderInterface
	PrimaryKey() MysqlColumnBuilderInterface
	Index() MysqlColumnBuilderInterface
	Unique() MysqlColumnBuilderInterface
	ToSql() string
	GetKeyPartSql() string
}

Mysql column's builder

type MysqlColumnType

type MysqlColumnType string

Mysql column type

const (
	MysqlColumnTypeTinyint    MysqlColumnType = "TINYINT"
	MysqlColumnTypeSmallint   MysqlColumnType = "SMALLINT"
	MysqlColumnTypeMediumint  MysqlColumnType = "MEDIUMINT"
	MysqlColumnTypeInteger    MysqlColumnType = "INT"
	MysqlColumnTypeBigint     MysqlColumnType = "BIGINT"
	MysqlColumnTypeFloat      MysqlColumnType = "FLOAT"
	MysqlColumnTypeDouble     MysqlColumnType = "DOUBLE"
	MysqlColumnTypeDecimal    MysqlColumnType = "DECIMAL"
	MysqlColumnTypeChar       MysqlColumnType = "CHAR"
	MysqlColumnTypeVarchar    MysqlColumnType = "VARCHAR"
	MysqlColumnTypeTinytext   MysqlColumnType = "TINYTEXT"
	MysqlColumnTypeText       MysqlColumnType = "TEXT"
	MysqlColumnTypeMediumtext MysqlColumnType = "MEDIUMTEXT"
	MysqlColumnTypeLongText   MysqlColumnType = "LONGTEXT"
	MysqlColumnTypeBinary     MysqlColumnType = "BINARY"
	MysqlColumnTypeVarbinary  MysqlColumnType = "VARBINARY"
	MysqlColumnTypeTinyblob   MysqlColumnType = "TINYBLOB"
	MysqlColumnTypeBlob       MysqlColumnType = "BLOB"
	MysqlColumnTypeMediumblob MysqlColumnType = "MEDIUMBLOB"
	MysqlColumnTypeLongblob   MysqlColumnType = "LONGBLOB"
	MysqlColumnTypeDatetime   MysqlColumnType = "DATETIME"
	MysqlColumnTypeTimestamp  MysqlColumnType = "TIMESTAMP"
)

type MysqlKeyType

type MysqlKeyType string

Mysql key type Example: Primary Key, Index, Unique

const (
	MysqlKeyTypeNone       MysqlKeyType = ""
	MysqlKeyTypePrimaryKey MysqlKeyType = "PRIMARY KEY"
	MysqlKeyTypeIndex      MysqlKeyType = "KEY"
	MysqlKeyTypeUnique     MysqlKeyType = "UNIQUE"
)

type MysqlNullableType

type MysqlNullableType int

Mysql nullable type

const (
	MysqlNullableTypeDefault MysqlNullableType = iota
	MysqlNullableTypeNull
	MysqlNullableTypeNotNull
)

type NextHandler

type NextHandler func() []byte

the next Handler. The processing method of Middleware

type PluginConfigInterface

type PluginConfigInterface interface {
	Init()
}

type PluginInterface

type PluginInterface interface {
	Init(configInterface PluginConfigInterface)
}

type RecoverHandler

type RecoverHandler func(rec interface{}) RecoverHandlerResult

component recover handler

type RecoverHandlerResult

type RecoverHandlerResult uint8

recover handler result

const (
	RecoverHandlerResultPass  RecoverHandlerResult = iota // It mean the panic was recover
	RecoverHandlerResultPanic                             // It mean the panic was not recover and panic again
)

BaseComponent

type RecoverInterface

type RecoverInterface interface {
	Error() string
	GetError() error
}

recoverable interface

type RouteHandler

type RouteHandler func(ctxI ContextInterface) []byte

route Handler Such as: Custom Handler, ControllerAction Handler

type RuleInterface

type RuleInterface interface {
	// get fields of validation
	Fields() []string
	// get handlers of validation
	Handlers() []ValidHandler
}

rule

type SessionInterface

type SessionInterface interface {
	// get sessionId
	GetSessionId() string
	// set key-value in session
	Set(key string, value interface{})
	// get value by key
	Get(key string) interface{}
	// delete value by key
	Del(key string)
	// destroy session
	Destroy()
}

session interface

type SocketConnHandler

type SocketConnHandler func(conn net.Conn)

socket conn handler

type SocketRouteHandler

type SocketRouteHandler func(conn net.Conn) []byte

socket custom route handler

type ValidHandler

type ValidHandler func(value reflect.Value) error

valid handler

type ValidInterface

type ValidInterface interface {
	// get rules
	Rules() []RuleInterface
}

valid interface

type ValidMode

type ValidMode uint8

valid mode priority level

type ValidationComponentInterface

type ValidationComponentInterface interface {
	// valid struct
	Valid(v interface{}) map[string][]error
}

validation component interface

type WebsocketRouteHandler

type WebsocketRouteHandler func(conn *websocket.Conn) []byte

websocket custom route handler

Jump to

Keyboard shortcuts

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