registry

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2022 License: Apache-2.0 Imports: 9 Imported by: 1

README

cosgo

go game 开发中

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FuncName

func FuncName(i interface{}) (fname string)

func IsExported

func IsExported(name string) bool

func ValueOf

func ValueOf(i interface{}) reflect.Value

Types

type Node

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

func (*Node) Binder

func (this *Node) Binder() interface{}

func (*Node) Call

func (this *Node) Call(args ...interface{}) (r []reflect.Value)

func (*Node) IsFunc

func (this *Node) IsFunc() bool

IsFunc 判断是func

func (*Node) IsMethod

func (this *Node) IsMethod() bool

IsMethod 对象中的方法

func (*Node) Method

func (this *Node) Method() (fun interface{})

func (*Node) Value

func (this *Node) Value() reflect.Value

type Options

type Options struct {
	Format func(string) string        //格式化路径
	Filter func(*Service, *Node) bool //用于判断struct中的方法是否合法接口
	// contains filtered or unexported fields
}

func NewOptions

func NewOptions() *Options

func (*Options) Clean

func (this *Options) Clean(paths ...string) (r string)

Clean 将所有path 格式化成 /a/b 模式

type Registry

type Registry struct {
	*Options
	// contains filtered or unexported fields
}

func New

func New(opts *Options) *Registry

func (*Registry) Get

func (this *Registry) Get(name string) (srv *Service, ok bool)

func (*Registry) Has

func (this *Registry) Has(name string) (ok bool)

func (*Registry) Len

func (this *Registry) Len() int

func (*Registry) Match

func (this *Registry) Match(path string) (srv *Service, ok bool)

Match 通过路径匹配Route,path必须是使用 Registry.Clean()处理后的

func (*Registry) Register

func (this *Registry) Register(i interface{}) error

Register 默认根路径注册

func (*Registry) Service

func (this *Registry) Service(name string) *Service

Service GET OR CREATE

func (*Registry) Services

func (this *Registry) Services() (r []*Service)

Services 获取所有ServicePath

type Service

type Service struct {
	*Options
	// contains filtered or unexported fields
}

func NewService

func NewService(name string, opts *Options) *Service

func (*Service) Match

func (this *Service) Match(path string) (node *Node, ok bool)

Match 匹配一个路径 path : $prefix/$methodName path : $prefix/$nodeName/$methodName

func (*Service) Name

func (this *Service) Name() string

func (*Service) Paths

func (this *Service) Paths() (r []string)

func (*Service) Prefix

func (this *Service) Prefix() string

func (*Service) Register

func (this *Service) Register(i interface{}, prefix ...string) error

Register 服务注册

func (*Service) RegisterFun

func (this *Service) RegisterFun(i interface{}, prefix ...string) error

func (*Service) RegisterStruct

func (this *Service) RegisterStruct(i interface{}, prefix ...string) error

Register 注册一组handle

Jump to

Keyboard shortcuts

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