Documentation ¶
Index ¶
- Constants
- Variables
- func Name(name string, value interface{}) string
- func Run(arg ...string) string
- type Action
- type Cache
- type Command
- type Config
- type Context
- func (c *Context) Begin(m *Message, arg ...string) *Context
- func (c *Context) Cap(key string, arg ...interface{}) string
- func (c *Context) Close(m *Message, arg ...string) bool
- func (c *Context) Cmd(m *Message, cmd string, key string, arg ...string) *Message
- func (c *Context) ID() int32
- func (c *Context) Merge(s *Context, x Server) *Context
- func (c *Context) Register(s *Context, x Server, name ...string) *Context
- func (c *Context) Server() Server
- func (c *Context) Spawn(m *Message, name string, help string, arg ...string) *Context
- func (c *Context) Start(m *Message, arg ...string) bool
- type Error
- type Frame
- type Message
- func (m *Message) Add(key string, arg ...string) *Message
- func (m *Message) AddCmd(cmd *Command) string
- func (m *Message) Append(key string, arg ...interface{}) string
- func (m *Message) Appendv(key string, arg ...interface{}) []string
- func (m *Message) Assert(arg interface{}) bool
- func (m *Message) Back(res *Message) *Message
- func (m *Message) CSV(text string, head ...string) *Message
- func (m *Message) Call(sync bool, cb func(*Message) *Message) *Message
- func (m *Message) Cap(arg ...interface{}) string
- func (m *Message) Capv(arg ...interface{}) interface{}
- func (m *Message) Cmd(arg ...interface{}) *Message
- func (m *Message) Cmdx(arg ...interface{}) string
- func (m *Message) Cmdy(arg ...interface{}) *Message
- func (m *Message) Conf(arg ...interface{}) string
- func (m *Message) Confi(arg ...interface{}) int
- func (m *Message) Confm(key string, chain interface{}, cbs ...interface{}) map[string]interface{}
- func (m *Message) Confv(arg ...interface{}) (val interface{})
- func (m *Message) Copy(msg *Message, arg ...string) *Message
- func (m *Message) Cost(str string, arg ...interface{}) *Message
- func (m *Message) Debug(str string, arg ...interface{})
- func (m *Message) Detail(arg ...interface{}) string
- func (m *Message) Detailv(arg ...interface{}) []string
- func (m *Message) Done() bool
- func (m *Message) Echo(str string, arg ...interface{}) *Message
- func (m *Message) Error(err bool, str string, arg ...interface{}) bool
- func (m *Message) Event(key string, arg ...string) *Message
- func (m *Message) Format(key interface{}) string
- func (m *Message) Formats(key string) string
- func (m *Message) Gos(msg *Message, cb func(*Message)) *Message
- func (m *Message) Grow(key string, chain interface{}, data interface{}) int
- func (m *Message) Grows(key string, chain interface{}, match string, value string, cb interface{}) map[string]interface{}
- func (m *Message) Hold(n int) *Message
- func (m *Message) Info(str string, arg ...interface{}) *Message
- func (m *Message) Load(arg ...string) *Message
- func (m *Message) Log(level string, str string, arg ...interface{}) *Message
- func (m *Message) Log_AUTH(arg ...interface{}) *Message
- func (m *Message) Log_CONF(arg ...interface{}) *Message
- func (m *Message) Log_CREATE(arg ...interface{}) *Message
- func (m *Message) Log_DELETE(arg ...interface{}) *Message
- func (m *Message) Log_EXPORT(arg ...interface{}) *Message
- func (m *Message) Log_IMPORT(arg ...interface{}) *Message
- func (m *Message) Log_INSERT(arg ...interface{}) *Message
- func (m *Message) Log_MODIFY(arg ...interface{}) *Message
- func (m *Message) Log_REMOVE(arg ...interface{}) *Message
- func (m *Message) Log_SELECT(arg ...interface{}) *Message
- func (m *Message) Logs(level string, arg ...interface{}) *Message
- func (m *Message) Option(key string, arg ...interface{}) string
- func (m *Message) Options(key string, arg ...interface{}) bool
- func (m *Message) Optionv(key string, arg ...interface{}) interface{}
- func (m *Message) Parse(meta string, key string, arg ...string) *Message
- func (m *Message) Prefix(arg ...string) string
- func (m *Message) Push(key string, value interface{}, arg ...interface{}) *Message
- func (m *Message) PushAction(list ...interface{})
- func (m *Message) PushDetail(value interface{}, arg ...interface{}) *Message
- func (m *Message) Render(cmd string, args ...interface{}) *Message
- func (m *Message) Result(arg ...interface{}) string
- func (m *Message) Resultv(arg ...interface{}) []string
- func (m *Message) Rich(key string, chain interface{}, data interface{}) string
- func (m *Message) Richs(key string, chain interface{}, raw interface{}, cb interface{}) (res map[string]interface{})
- func (m *Message) Right(arg ...interface{}) bool
- func (m *Message) Save(arg ...string) *Message
- func (m *Message) Search(key interface{}, cb interface{}) *Message
- func (m *Message) Set(key string, arg ...string) *Message
- func (m *Message) Sleep(arg string) *Message
- func (m *Message) Sort(key string, arg ...string) *Message
- func (m *Message) Source() *Context
- func (m *Message) Space(arg interface{}) []string
- func (m *Message) Spawn(arg ...interface{}) *Message
- func (m *Message) Spawns(arg ...interface{}) *Message
- func (m *Message) Split(str string, field string, space string, enter string) *Message
- func (m *Message) Start(key string, arg ...string) *Message
- func (m *Message) Starts(name string, help string, arg ...string) *Message
- func (m *Message) Table(cbs ...func(index int, value map[string]string, head []string)) *Message
- func (m *Message) Target() *Context
- func (m *Message) Time(args ...interface{}) string
- func (m *Message) Travel(cb interface{}) *Message
- func (m *Message) TryCatch(msg *Message, safe bool, hand ...func(msg *Message)) *Message
- func (m *Message) Warn(err bool, arg ...interface{}) bool
- func (m *Message) Watch(key string, arg ...string) *Message
- type Server
Constants ¶
View Source
const ( MOD_DIR = 0750 MOD_FILE = 0640 MOD_CHAN = 16 MOD_BUF = 1024 MOD_DATE = "2006-01-02" MOD_TIME = "2006-01-02 15:04:05" )
View Source
const ( MSG_DETAIL = "detail" MSG_OPTION = "option" MSG_APPEND = "append" MSG_RESULT = "result" MSG_ALIAS = "_alias" MSG_SOURCE = "_source" MSG_TARGET = "_target" MSG_HANDLE = "_handle" MSG_ACTION = "_action" MSG_OUTPUT = "_output" MSG_ARGS = "_args" MSG_CMDS = "cmds" MSG_SESSID = "sessid" MSG_DOMAIN = "domain" MSG_USERIP = "user.ip" MSG_USERUA = "user.ua" MSG_USERURL = "user.url" MSG_USERWEB = "user.web" MSG_USERPOD = "user.pod" MSG_USERNICK = "user.nick" MSG_USERNAME = "user.name" MSG_USERZONE = "user.zone" MSG_USERROLE = "user.role" MSG_USERDATA = "user.data" MSG_USERADDR = "user.addr" MSG_RIVER = "sess.river" MSG_STORM = "sess.storm" MSG_ACTIVE = "sess.active" )
View Source
const ( CTX_STREAM = "stream" CTX_STATUS = "status" CTX_FOLLOW = "follow" CTX_INIT = "_init" CTX_EXIT = "_exit" CTX_BEGIN = "begin" CTX_START = "start" CTX_SERVE = "serve" CTX_CLOSE = "close" )
View Source
const ( // 数据 LOG_IMPORT = "import" LOG_EXPORT = "export" LOG_CREATE = "create" LOG_REMOVE = "remove" LOG_INSERT = "insert" LOG_DELETE = "delete" LOG_SELECT = "select" LOG_MODIFY = "modify" // 事件 LOG_ENABLE = "enable" LOG_STATUS = "status" LOG_LISTEN = "listen" LOG_ACCEPT = "accept" LOG_FINISH = "finish" LOG_SIGNAL = "signal" LOG_TIMERS = "timers" LOG_EVENTS = "events" // 状态 LOG_BEGIN = "begin" LOG_START = "start" LOG_SERVE = "serve" LOG_CLOSE = "close" // 分类 LOG_CONF = "conf" LOG_CMDS = "cmds" LOG_AUTH = "auth" LOG_COST = "cost" LOG_INFO = "info" LOG_WARN = "warn" LOG_ERROR = "error" LOG_TRACE = "trace" LOG_DEBUG = "debug" )
View Source
const ( RENDER_VOID = "_void" RENDER_OUTPUT = "_output" RENDER_RESULT = "_result" RENDER_QRCODE = "_qrcode" RENDER_TEMPLATE = "_template" RENDER_DOWNLOAD = "_download" )
View Source
const ( EXPORT_LABEL = "lab" EXPORT_GROUP = "grp" FIELD_RELOAD = "field.reload" FIELD_DETAIL = "field.detail" )
Variables ¶
View Source
var ErrNameExists = "name already exists:"
View Source
var ErrNotAuth = "not auth: "
View Source
var ErrNotFound = "not found: "
View Source
var ErrWarn = "warn: "
View Source
var Index = &Context{Name: "ice", Help: "冰山模块", Caches: map[string]*Cache{ CTX_FOLLOW: {Value: ""}, CTX_STREAM: {Value: "shy"}, CTX_STATUS: {Value: "begin"}, }, Configs: map[string]*Config{ "help": {Value: map[string]interface{}{ "index": []interface{}{ "^_^ 欢迎使用冰山框架 ^_^", "^_^ Welcome to Icebergs world ^_^", "", "Meet: shylinuxc@gmail.com", "More: https://shylinux.com", "More: https://github.com/shylinux/icebergs", "", }, }}, "task": {Value: kit.Dict( kit.MDB_STORE, "var/data", kit.MDB_LIMIT, "110", kit.MDB_LEAST, "100", )}, }, Commands: map[string]*Command{ CTX_INIT: {Hand: func(m *Message, c *Context, cmd string, arg ...string) { defer m.Cost("_init ice") m.Travel(func(p *Context, c *Context) { if cmd, ok := c.Commands[CTX_INIT]; ok && p != nil { c.cmd(m.Spawns(c), cmd, CTX_INIT, arg...) } }) }}, "init": {Name: "init", Help: "启动", Hand: func(m *Message, c *Context, cmd string, arg ...string) { m.root.Cmd(CTX_INIT) m.target.root.wg = &sync.WaitGroup{} for _, k := range kit.Split(kit.Select("gdb,log,ssh,ctx", os.Getenv("ctx_mod"))) { m.Start(k) } m.Cmd("ssh.source", "etc/init.shy", "init.shy", "启动配置") m.Cmdy(arg) }}, "help": {Name: "help", Help: "帮助", Hand: func(m *Message, c *Context, cmd string, arg ...string) { m.Echo(strings.Join(kit.Simple(m.Confv("help", "index")), "\n")) }}, "name": {Name: "name", Help: "命名", Hand: func(m *Message, c *Context, cmd string, arg ...string) { for k, v := range names { m.Push("key", k) switch v := v.(type) { case *Context: m.Push("value", v.Name) default: m.Push("value", "") } } m.Sort("key") }}, "exit": {Name: "exit", Help: "结束", Hand: func(m *Message, c *Context, cmd string, arg ...string) { m.root.target.server.(*Frame).code = kit.Int(kit.Select("0", arg, 0)) m.Cmd("ssh.source", "etc/exit.shy", "exit.shy", "退出配置") m.root.Cmd(CTX_EXIT) }}, CTX_EXIT: {Hand: func(m *Message, c *Context, cmd string, arg ...string) { defer m.Cost(CTX_EXIT) m.root.Travel(func(p *Context, c *Context) { if cmd, ok := c.Commands[CTX_EXIT]; ok && p != nil { m.TryCatch(m.Spawns(c), true, func(msg *Message) { c.cmd(msg, cmd, CTX_EXIT, arg...) }) } }) wait <- true }}, }, }
View Source
var Log func(*Message, string, string)
View Source
var Loop func()
Functions ¶
Types ¶
type Context ¶
type Context struct { Name string Help interface{} // string []string Test interface{} // string []string Caches map[string]*Cache Configs map[string]*Config Commands map[string]*Command // contains filtered or unexported fields }
type Message ¶
type Message struct { Hand bool W http.ResponseWriter R *http.Request O io.Writer I io.Reader // contains filtered or unexported fields }
func (*Message) Log_CREATE ¶ added in v0.2.3
func (*Message) Log_DELETE ¶ added in v0.2.3
func (*Message) Log_EXPORT ¶ added in v0.2.3
func (*Message) Log_IMPORT ¶ added in v0.2.3
func (*Message) Log_INSERT ¶ added in v0.2.3
func (*Message) Log_MODIFY ¶ added in v0.2.3
func (*Message) Log_REMOVE ¶ added in v0.2.3
func (*Message) Log_SELECT ¶ added in v0.2.3
func (*Message) PushAction ¶ added in v0.2.4
func (m *Message) PushAction(list ...interface{})
func (*Message) PushDetail ¶ added in v0.2.4
Source Files ¶
Click to show internal directories.
Click to hide internal directories.