service

package
v0.0.0-...-c340371 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2018 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package service is main loop logic

Index

Constants

View Source
const (
	ON_SERVICE_DOWN = "ON_SERVICE_DOWN"
	REQUEST_TIMEOUT = 3 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Method

type Method struct {
	*event.Method
}

func NewMethod

func NewMethod(m interface{}) *Method

type ProcessorClient

type ProcessorClient struct {
	*SettingContainer

	*session.Session
	// contains filtered or unexported fields
}

func NewProcessorClient

func NewProcessorClient(cli transfer.IClient) *ProcessorClient

for server

func (*ProcessorClient) AddListener

func (s *ProcessorClient) AddListener(route string, callback interface{})

func (*ProcessorClient) Connect

func (s *ProcessorClient) Connect(host string, port int) error

func (*ProcessorClient) RegistFilter

func (self *ProcessorClient) RegistFilter(filter filter.IFilter)

func (*ProcessorClient) SetFilters

func (self *ProcessorClient) SetFilters(filters []filter.IFilter)

func (*ProcessorClient) SetHeartBeatManager

func (self *ProcessorClient) SetHeartBeatManager(f filter.IFilter)

func (*ProcessorClient) SetRouter

func (self *ProcessorClient) SetRouter(router *router.Router)

type Service

type Service struct {
	transfer.IServer
	*SettingContainer

	Name     string
	Encoding pkg.EncodingType
	// contains filtered or unexported fields
}

func NewService

func NewService(name string, serv transfer.IServer) *Service

func (*Service) FilterOnNewClient

func (self *Service) FilterOnNewClient(sess *session.Session) bool

func (*Service) Filters

func (self *Service) Filters() []filter.IFilter

func (*Service) HandlerOnNewClient

func (self *Service) HandlerOnNewClient(sess *session.Session)

func (*Service) Handlers

func (self *Service) Handlers() []handler.IHandler

func (*Service) OnBeforeStop

func (self *Service) OnBeforeStop()

func (*Service) OnError

func (self *Service) OnError(err error)

func (*Service) OnNewClient

func (self *Service) OnNewClient(client transfer.IClient)

func (*Service) OnStarted

func (self *Service) OnStarted()

func (*Service) OnStopped

func (self *Service) OnStopped()

func (*Service) RegistFilter

func (self *Service) RegistFilter(obj filter.IFilter)

func (*Service) RegistHanlder

func (self *Service) RegistHanlder(obj handler.IHandler)

func (*Service) RegistHanlderGroup

func (self *Service) RegistHanlderGroup(group map[string][]handler.IHandler)

func (*Service) RegistNewClient

func (self *Service) RegistNewClient(client transfer.IClient) *ProcessorClient

func (*Service) Router

func (self *Service) Router() *router.Router

func (*Service) ServiceClients

func (self *Service) ServiceClients() []*ProcessorClient

func (*Service) SetEncoding

func (self *Service) SetEncoding(e pkg.EncodingType) error

func (*Service) SetSettings

func (self *Service) SetSettings(s *Settings) error

type ServiceClient

type ServiceClient struct {
	*SettingContainer

	*session.Session
	// contains filtered or unexported fields
}

func NewServiceClient

func NewServiceClient(cli transfer.IClient) *ServiceClient

for client

func (*ServiceClient) AddListener

func (s *ServiceClient) AddListener(route string, callback interface{})

func (*ServiceClient) Connect

func (s *ServiceClient) Connect(host string, port int) error

func (*ServiceClient) Notify

func (s *ServiceClient) Notify(route string, data interface{}) error

func (*ServiceClient) Push

func (s *ServiceClient) Push(route string, data interface{}) error

func (*ServiceClient) RegistFilter

func (self *ServiceClient) RegistFilter(filter filter.IFilter)

func (*ServiceClient) Request

func (s *ServiceClient) Request(route string, data interface{}, succCb interface{}, failCb func(*pkg.ErrorMessage)) error

func (*ServiceClient) SetFilters

func (self *ServiceClient) SetFilters(filters []filter.IFilter)

func (*ServiceClient) SetHeartBeatManager

func (self *ServiceClient) SetHeartBeatManager(f filter.IFilter)

type SettingContainer

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

func NewSettingContainer

func NewSettingContainer() *SettingContainer

func (*SettingContainer) SetSettings

func (sc *SettingContainer) SetSettings(s *Settings) error

func (*SettingContainer) Settings

func (sc *SettingContainer) Settings() *Settings

type Settings

type Settings struct {
	IsDisconnectOnError bool
}

func DefaultSettings

func DefaultSettings() *Settings

Jump to

Keyboard shortcuts

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