wic

package module
v0.0.0-...-d9894f7 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: GPL-3.0 Imports: 17 Imported by: 1

README

wic

wic框架

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddServerFactory

func AddServerFactory(fun ServerFunc) bool

Types

type CallBack

type CallBack func() interface{}

type CallBackMap

type CallBackMap map[string]interface{}

type CallBackTopic

type CallBackTopic func(id int, data interface{}) bool

type Data

type Data struct {
	Fd  int64
	Ser Server
}

type Fd

type Fd struct {
	Id       uint64
	Ser      Server
	Validate bool
	Value    interface{}
}

func GetFd

func GetFd(id uint64) *Fd

func NewFd

func NewFd(ser Server, v interface{}) *Fd

func (*Fd) IdString

func (fd *Fd) IdString() string

func (*Fd) SetValidate

func (fd *Fd) SetValidate(v bool)

type Http

type Http struct {
	ServerRealize
	// contains filtered or unexported fields
}

func (*Http) GetRaw

func (h *Http) GetRaw(name string) interface{}

func (*Http) Read

func (h *Http) Read(fd *Fd) string

func (*Http) Run

func (h *Http) Run(blocking bool) error

func (*Http) Send

func (h *Http) Send(fd *Fd, data string) bool

func (*Http) ServeHTTP

func (h *Http) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Http) Write

func (h *Http) Write(fd *Fd, data string) bool

type IO

type IO interface {
	Close(fd *Fd) bool
	Read(fd *Fd) string
	Write(fd *Fd, data string) bool

	Send(fd *Fd, data string) bool
}

socket io

type Id

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

func NewId

func NewId() *Id

func (*Id) Add

func (id *Id) Add(fd int64, ser Server) bool

func (*Id) Check

func (id *Id) Check(fd int64) Server

type Logic

type Logic interface {
	IO
	News()
	Init(ser Server) bool
	End(ser Server) bool

	SetServer(ser Server) bool
	AddServer(ser Server) bool
	GetServer(name string) map[uint]Server

	GetServerList() ServerMap

	Connect(ser Server, fd *Fd) bool
	Receive(ser Server, fd *Fd, data string) bool
	Closes(ser Server, fd *Fd) bool
}

逻辑业务接口

type LogicRealize

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

func (*LogicRealize) AddServer

func (lr *LogicRealize) AddServer(ser Server) bool

func (*LogicRealize) Close

func (lr *LogicRealize) Close(fd *Fd) bool

func (*LogicRealize) Closes

func (lr *LogicRealize) Closes(ser Server, fd *Fd) bool

func (*LogicRealize) Connect

func (lr *LogicRealize) Connect(ser Server, fd *Fd) bool

func (*LogicRealize) End

func (lr *LogicRealize) End(ser Server) bool

func (*LogicRealize) GetServer

func (lr *LogicRealize) GetServer(name string) map[uint]Server

func (*LogicRealize) GetServerList

func (lr *LogicRealize) GetServerList() ServerMap

func (*LogicRealize) Init

func (lr *LogicRealize) Init(ser Server) bool

func (*LogicRealize) News

func (lr *LogicRealize) News()

func (*LogicRealize) Read

func (lr *LogicRealize) Read(fd *Fd) string

func (*LogicRealize) Receive

func (lr *LogicRealize) Receive(ser Server, fd *Fd, data string) bool

func (*LogicRealize) Send

func (lr *LogicRealize) Send(fd *Fd, data string) bool

func (*LogicRealize) SetServer

func (lr *LogicRealize) SetServer(ser Server) bool

func (*LogicRealize) Write

func (lr *LogicRealize) Write(fd *Fd, data string) bool

type Message

type Message interface{}

type MessageQueue

type MessageQueue struct {
	Tcp
	// contains filtered or unexported fields
}

消息队列

type Mq

type Mq MessageQueue

func (*Mq) Run

func (mq *Mq) Run(blocking bool) error

func (*Mq) SetTopic

func (mq *Mq) SetTopic(number uint, size uint)

设置主题参数

func (*Mq) Topic

func (mq *Mq) Topic(name string) *Topic

获得主题,没有则新建

type Queue

type Queue chan Message

func (Queue) Add

func (queue Queue) Add(msg Message) bool

往队列添加消息

func (Queue) Read

func (queue Queue) Read(len int) []Message

从队列读取消息

func (Queue) Readk

func (queue Queue) Readk(len int) []Message

type RouterCallBack

type RouterCallBack func(http.ResponseWriter, *http.Request)

type Server

type Server interface {
	IO
	Init()
	GetPort() uint

	GetName() []string
	IsName(name string) bool
	SetName(name []string) bool

	Run(blocking bool) error
	SetIpPort(ip string, port int)
	SetLogic(logic Logic) bool

	GetRaw(name string) interface{}
	// contains filtered or unexported methods
}

服务解析处理接口

func NewHttp

func NewHttp() Server

func NewMq

func NewMq() Server

func NewTcp

func NewTcp() Server

func NewWeb

func NewWeb() Server

func NewWebSocket

func NewWebSocket() Server

type ServerFactory

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

func GetServerFactory

func GetServerFactory() *ServerFactory

func NewServerFactory

func NewServerFactory() *ServerFactory

func (*ServerFactory) Create

func (sf *ServerFactory) Create(name string) Server

func (*ServerFactory) On

func (sf *ServerFactory) On(url string, logic Logic) (Server, int)

func (*ServerFactory) Router

func (sf *ServerFactory) Router(url string) (Server, int)

type ServerFunc

type ServerFunc func() Server

type Greeting func(name string) string

type ServerMap

type ServerMap map[string]map[uint]Server

type ServerRealize

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

func (*ServerRealize) Close

func (sr *ServerRealize) Close(fd *Fd) bool

func (*ServerRealize) GetName

func (sr *ServerRealize) GetName() []string

func (*ServerRealize) GetPort

func (sr *ServerRealize) GetPort() uint

func (*ServerRealize) GetRaw

func (sr *ServerRealize) GetRaw(name string) interface{}

func (*ServerRealize) Init

func (sr *ServerRealize) Init()

func (*ServerRealize) IsName

func (sr *ServerRealize) IsName(name string) bool

func (*ServerRealize) SetIpPort

func (sr *ServerRealize) SetIpPort(ip string, port int)

func (*ServerRealize) SetLogic

func (sr *ServerRealize) SetLogic(logic Logic) bool

func (*ServerRealize) SetName

func (sr *ServerRealize) SetName(name []string) bool

type Tcp

type Tcp struct {
	ServerRealize
	// contains filtered or unexported fields
}

func (*Tcp) Close

func (tcp *Tcp) Close(fd *Fd) bool

func (*Tcp) Read

func (tcp *Tcp) Read(fd *Fd) string

func (*Tcp) Run

func (tcp *Tcp) Run(blocking bool) error

func (*Tcp) Send

func (tcp *Tcp) Send(fd *Fd, data string) bool

func (*Tcp) Write

func (tcp *Tcp) Write(fd *Fd, data string) bool

type Template

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

模板

func (*Template) Assign

func (tpl *Template) Assign(name string, v interface{}) bool

赋值

func (*Template) Display

func (tpl *Template) Display(name string) bool

显示/渲染

func (*Template) Error

func (tpl *Template) Error(err error) bool

错误输出

func (*Template) GetContext

func (tpl *Template) GetContext() CallBackMap

func (*Template) SetTemplateDir

func (tpl *Template) SetTemplateDir(dir string)

设置模板路径

type Topic

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

主题/订阅

func (*Topic) AddQueue

func (topic *Topic) AddQueue(number int, size uint) int

添加队列

func (*Topic) CallBack

func (topic *Topic) CallBack(callback CallBackTopic, args ...int) bool

func (*Topic) GetName

func (topic *Topic) GetName() string

获得主题名称

func (*Topic) GetQueue

func (topic *Topic) GetQueue(id int) Queue

func (*Topic) NewQueue

func (topic *Topic) NewQueue(number uint, size uint)

创建并初始化消息队列

func (*Topic) Read

func (topic *Topic) Read(id, len int) []Message

读取消息(消费者)

func (*Topic) Send

func (topic *Topic) Send(msg Message) (int, int)

发送消息(生产者)

func (*Topic) SetCallBack

func (topic *Topic) SetCallBack(id int, callbak CallBackTopic) bool

func (*Topic) SetName

func (topic *Topic) SetName(name string)

设置主题名称

func (*Topic) SetPush

func (topic *Topic) SetPush(id int, _url string)

type Web

type Web struct {
	Http

	Router    map[string]interface{}
	TplRouter map[string]interface{}
	// contains filtered or unexported fields
}

func (*Web) AddRouter

func (web *Web) AddRouter(reg string, lsp interface{}) bool

添加路由处理函数

func (*Web) AddTemplateRouter

func (web *Web) AddTemplateRouter(reg string, lsp interface{}) bool

添加模板路由处理函数

func (*Web) GetDir

func (web *Web) GetDir() string

func (*Web) Run

func (web *Web) Run(blocking bool) error

开始运行

func (*Web) ServeHTTP

func (web *Web) ServeHTTP(w http.ResponseWriter, r *http.Request)

net/http包的接口实现

func (*Web) SetDir

func (web *Web) SetDir(dir string)

func (*Web) SetRouterAutomatic

func (web *Web) SetRouterAutomatic(ok bool)

设置路由器状态

func (*Web) SetTemplateDir

func (web *Web) SetTemplateDir(dir string)

设置模板路径

func (*Web) Template

func (web *Web) Template(w http.ResponseWriter) *Template

获取模板

func (*Web) TplOut

func (web *Web) TplOut(w http.ResponseWriter, path string, data map[string]interface{}) bool

type WebSocket

type WebSocket struct {
	ServerRealize
}

func (*WebSocket) Read

func (ws *WebSocket) Read(fd *Fd) string

func (*WebSocket) Run

func (ws *WebSocket) Run(blocking bool) error

func (*WebSocket) Send

func (ws *WebSocket) Send(fd *Fd, data string) bool

func (*WebSocket) Write

func (ws *WebSocket) Write(fd *Fd, data string) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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