kada

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

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

Go to latest
Published: Sep 15, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

README

kada.go

wiki

【Redis】

// 导入模块
import "github.com/D-Deo/kada.go/service/redis"
// 注册 redis 连接信息
redis.Set(tag, redis.NewClient(host, port, db, pass))

// 执行 redis 命令(命令参考官方,完全一致)
reply, err := redis.Get(tag).Exec(cmd, key, args)

// 快捷指令(GET)
str = redis.Get(tag).Get(key)

// 快捷指令(HGETALL)
maps = redis.Get(tag).HGetAll(key)

【MongoDB】

// 导入模块
import "github.com/D-Deo/kada.go/service/mongo"
// 连接MongoDB
// params:
//  -- uri: mongo连接字符串, ep: mongo://xxx.xxx.xxx.xxx:xxxx
//  -- db: 数据库
mongo.Connect(uri, db)

【Thrift】

// 导入模块
import "github.com/D-Deo/kada.go/rpc/thrift"
// 创建服务监听对象
handler := &XXXService{}
// 创建服务进程对象
processor := ads.NewXXXServiceProcessor(handler)
// 创建ThriftRPC服务
server := thrift.NewServer()
// 启动服务
server.Start(port, processor, "", true, false, false)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Panic

func Panic()

捕获异常

func Run

func Run()

启动程序

Types

type IHandler

type IHandler interface {
	Handle(string, int32, []byte) error
}

type IService

type IService interface {
	Startup() error
	Call(string, string, interface{}, interface{}) error
}

type Message

type Message struct {
	Handle string
	Action string
	Args   interface{}
	Back   interface{}
}

type Service

type Service struct {
	Recv chan Message
	Send chan error

	Handlers map[string]reflect.Value
}

func NewService

func NewService() *Service

创建服务

func (*Service) Call

func (o *Service) Call(handle string, action string, args interface{}, back interface{}) error

调用服务

func (*Service) Handle

func (o *Service) Handle()

控制服务

func (*Service) Register

func (o *Service) Register(name string, handler interface{})

注册服务

func (*Service) Start

func (o *Service) Start()

启动服务

Directories

Path Synopsis
plugins
rpc
service

Jump to

Keyboard shortcuts

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