micro

package
v0.0.0-...-0e6b51b Latest Latest
Warning

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

Go to latest
Published: May 11, 2020 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const ERRNO_OK = 200

Variables

This section is empty.

Functions

func AddDefaultService

func AddDefaultService(service Service)

func GetConfigWithFile

func GetConfigWithFile(configFile string) (interface{}, error)

func HandleFunc

func HandleFunc(app *App, s svc.Server) func(http.ResponseWriter, *http.Request)

Types

type App

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

func NewApp

func NewApp(name string, errno int, config interface{}, ss []Service) (*App, error)

func NewAppWithConfig

func NewAppWithConfig(config interface{}, ss []Service) (*App, error)

func NewAppWithConfigFile

func NewAppWithConfigFile(configFile string) (*App, error)

func NewAppWithEnv

func NewAppWithEnv() (*App, error)

func (*App) AddService

func (A *App) AddService(service Service)

func (*App) Each

func (A *App) Each(cb func(name string, entry *Entry) bool)

func (*App) Errno

func (A *App) Errno() int

func (*App) GetConfig

func (A *App) GetConfig() interface{}

func (*App) GetDB

func (A *App) GetDB(name string) (*sql.DB, string, error)

func (*App) GetEntry

func (A *App) GetEntry(name string) *Entry

func (*App) GetName

func (A *App) GetName() string

func (*App) GetRedis

func (A *App) GetRedis(name string) (*redis.Client, string, error)

func (*App) GetSharedObject

func (A *App) GetSharedObject(key string, fn func() (SharedObject, error)) (SharedObject, error)

func (*App) NewID

func (A *App) NewID() int64

func (*App) ParseConfig

func (A *App) ParseConfig(name string, config interface{})

func (*App) Recycle

func (A *App) Recycle()

func (*App) SendMessage

func (A *App) SendMessage(name string, data interface{}) error

type Client

type Client interface {
	Recycle()
	Send(method string, name string, data interface{}) (interface{}, error)
}

func GetClient

func GetClient(app IContext, name string) (Client, error)

type Context

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

func NewContext

func NewContext(app *App, trace string, prefix string) *Context

func (*Context) GetApp

func (C *Context) GetApp() *App

func (*Context) GetCache

func (C *Context) GetCache(name string) (cache.ICache, error)

func (*Context) GetConfig

func (C *Context) GetConfig() interface{}

func (*Context) GetDB

func (C *Context) GetDB(name string) (*sql.DB, string, error)

func (*Context) GetRedis

func (C *Context) GetRedis(name string) (*redis.Client, string, error)

func (*Context) GetSharedObject

func (C *Context) GetSharedObject(key string, fn func() (SharedObject, error)) (SharedObject, error)

func (*Context) GetTrace

func (C *Context) GetTrace() string

func (*Context) NewID

func (C *Context) NewID() int64

func (*Context) Printf

func (C *Context) Printf(format string, v ...interface{})

func (*Context) Println

func (C *Context) Println(v ...interface{})

func (*Context) SendMessage

func (C *Context) SendMessage(name string, data interface{}) error

type Entry

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

func (*Entry) Handle

func (E *Entry) Handle(app *App, task Task, trace string) (interface{}, *Error)

func (*Entry) NewTask

func (E *Entry) NewTask(getValue func(name string) interface{}) Task

type Error

type Error struct {
	Errno  int    `json:"errno"`
	Errmsg string `json:"errmsg"`
}

func NewError

func NewError(errno int, errmsg string) *Error

func (*Error) Error

func (E *Error) Error() string

type HTTPClient

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

func NewHttpClient

func NewHttpClient(baseURL string) *HTTPClient

func (*HTTPClient) Recycle

func (C *HTTPClient) Recycle()

func (*HTTPClient) Send

func (C *HTTPClient) Send(method string, name string, data interface{}) (interface{}, error)

type IContext

type IContext interface {
	GetTrace() string
	GetConfig() interface{}
	GetApp() *App
	GetDB(name string) (*sql.DB, string, error)
	GetRedis(name string) (*redis.Client, string, error)
	GetCache(name string) (cache.ICache, error)
	GetSharedObject(key string, fn func() (SharedObject, error)) (SharedObject, error)
	SendMessage(name string, data interface{}) error
	NewID() int64
	Printf(fomrat string, v ...interface{})
	Println(v ...interface{})
}

type Recycle

type Recycle interface {
	Recycle()
}

type Service

type Service interface {
	GetTitle() string
}

type SharedObject

type SharedObject interface {
}

type Task

type Task interface {
	GetName() string
	GetTitle() string
}

Jump to

Keyboard shortcuts

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