1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- package micro
- import (
- "git.nspix.com/golang/micro/gateway/cli"
- "git.nspix.com/golang/micro/gateway/http"
- "git.nspix.com/golang/micro/gateway/rpc"
- "git.nspix.com/golang/micro/registry"
- "time"
- )
- var (
- std *Service
- )
- func Init(opts ...Option) *Service {
- std = New(opts...)
- return std
- }
- func Name() string {
- if std == nil {
- panic("init first")
- }
- return std.opts.Name
- }
- func Version() string {
- if std == nil {
- panic("init first")
- }
- return std.opts.Version
- }
- func Node() *registry.ServiceNode {
- if std == nil {
- panic("init first")
- }
- return std.Node()
- }
- func HttpServe() *http.Server {
- if std == nil {
- panic("init first")
- }
- return std.HttpServe()
- }
- func RPCServe() *rpc.Server {
- if std == nil {
- panic("init first")
- }
- return std.RPCServe()
- }
- func CliServe() *cli.Server {
- if std == nil {
- panic("init first")
- }
- return std.CliServe()
- }
- func PeekService(name string) ([]*registry.ServiceNode, error) {
- if std == nil {
- panic("init first")
- }
- return std.PeekService(name)
- }
- func Handle(method string, cb HandleFunc, opts ...HandleOption) {
- if std == nil {
- panic("init first")
- }
- std.Handle(method, cb, opts...)
- }
- func NewRequest(name, method string, body interface{}) (req *Request, err error) {
- if std == nil {
- panic("init first")
- }
- return std.NewRequest(name, method, body)
- }
- func DeferTick(duration time.Duration, callback HandleTickerFunc, opts ...TickOption) int64 {
- if std == nil {
- panic("init first")
- }
- return std.DeferTick(duration, callback, opts...)
- }
- func Environment() string {
- if std == nil {
- panic("init first")
- }
- return std.Environment()
- }
|