nano: github.com/lonng/nano/component Index | Files

package component

import "github.com/lonng/nano/component"

Index

Package Files

base.go component.go hub.go method.go options.go service.go

type Base Uses

type Base struct{}

Base implements a default component for Component.

func (*Base) AfterInit Uses

func (c *Base) AfterInit()

AfterInit was called after the component is initialized.

func (*Base) BeforeShutdown Uses

func (c *Base) BeforeShutdown()

BeforeShutdown was called before the component to shutdown.

func (*Base) Init Uses

func (c *Base) Init()

Init was called to initialize the component.

func (*Base) Shutdown Uses

func (c *Base) Shutdown()

Shutdown was called to shutdown the component.

type CompWithOptions Uses

type CompWithOptions struct {
    Comp Component
    Opts []Option
}

type Component Uses

type Component interface {
    Init()
    AfterInit()
    BeforeShutdown()
    Shutdown()
}

Component is the interface that represent a component.

type Components Uses

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

func (*Components) List Uses

func (cs *Components) List() []CompWithOptions

List returns all components with it's options

func (*Components) Register Uses

func (cs *Components) Register(c Component, options ...Option)

Register registers a component to hub with options

type Handler Uses

type Handler struct {
    Receiver reflect.Value  // receiver of method
    Method   reflect.Method // method stub
    Type     reflect.Type   // low-level type of method
    IsRawArg bool           // whether the data need to serialize
}

Handler represents a message.Message's handler's meta information. Handler represents a message.Message's handler's meta information.

type Option Uses

type Option func(options *options)

Option used to customize handler

func WithName Uses

func WithName(name string) Option

WithName used to rename component name

func WithNameFunc Uses

func WithNameFunc(fn func(string) string) Option

WithNameFunc override handler name by specific function such as: strings.ToUpper/strings.ToLower

func WithSchedulerName Uses

func WithSchedulerName(name string) Option

WithSchedulerName set the name of the service scheduler

type Service Uses

type Service struct {
    Name      string              // name of service
    Type      reflect.Type        // type of the receiver
    Receiver  reflect.Value       // receiver of methods for the service
    Handlers  map[string]*Handler // registered methods
    SchedName string              // name of scheduler variable in session data
    Options   options             // options
}

Service implements a specific service, some of it's methods will be called when the correspond events is occurred.

func NewService Uses

func NewService(comp Component, opts []Option) *Service

func (*Service) ExtractHandler Uses

func (s *Service) ExtractHandler() error

ExtractHandler extract the set of methods from the receiver value which satisfy the following conditions: - exported method of exported type - two arguments, both of exported type - the first argument is *session.Session - the second argument is []byte or a pointer

Package component imports 5 packages (graph) and is imported by 7 packages. Updated 2019-07-16. Refresh now. Tools for package owners.