app

package
v0.0.0-...-07235e0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2017 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package app 应用配置(包含路由和CheckSum计算)

收到IM信令后,根据信令名(例如:msg/foo/bar),查询信息的处理路由。 可以提供多种路由设置与维护方式,包括:本地配置文件、Redis服务、etcd服务和consul服务。

Index

Constants

View Source
const (
	// ContextAppController AppController名
	ContextAppController contextKey = "zim/appcontroller"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	ID         string  `json:"id"`
	Key        string  `json:"key"`
	KeyBytes   []byte  `json:"-"`
	RouteMap   InfoMap `json:"router"`
	Router     *Router `json:"-"`
	TokenCheck string  `json:"token-check"`
}

App 应用数据

func GetAppFromContext

func GetAppFromContext(ctx context.Context, appid string) *App

GetAppFromContext 从Context获取App

func NewApp

func NewApp(config string) (*App, error)

NewApp 新建App

func (*App) CheckSumMD5

func (app *App) CheckSumMD5(fields ...[]byte) string

CheckSumMD5 取得CheckSum MD5算法

func (*App) CheckSumSHA1

func (app *App) CheckSumSHA1(fields ...[]byte) string

CheckSumSHA1 取得CheckSum SHA1算法

func (*App) CheckSumSHA256

func (app *App) CheckSumSHA256(fields ...[]byte) string

CheckSumSHA256 取得CheckSum SHA256算法

type CheckSum

type CheckSum interface {
	CheckSumSHA1(fields ...[]byte) string
	CheckSumSHA256(fields ...[]byte) string
	CheckSumMD5(fields ...[]byte) string
}

CheckSum CheckSum接口

type Controller

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

Controller App map controller

func NewController

func NewController(configs []string) (*Controller, error)

NewController create a new controller from configs

func (*Controller) AddApp

func (controller *Controller) AddApp(app *App)

AddApp append an app into map (multi-thread unsafe!)

func (*Controller) GetApp

func (controller *Controller) GetApp(appid string) *App

GetApp find app by app ID

func (*Controller) SaveIntoContext

func (controller *Controller) SaveIntoContext(ctx context.Context) context.Context

SaveIntoContext 设置AppController到Context中

type Info

type Info struct {
	Broker string `json:"broker"`
	Tag    string `json:"tag"`
}

Info 最简单的路由信息

type InfoMap

type InfoMap map[string]Info

InfoMap 最简单的路由信息Map

type Router

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

Router 路由

func NewRouter

func NewRouter(routerMap InfoMap) (r *Router, err error)

NewRouter 新建Router

func (*Router) Find

func (r *Router) Find(name string) broker.Broker

Find 查询路由

func (*Router) String

func (r *Router) String() string

String 输出

Jump to

Keyboard shortcuts

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