Documentation ¶
Overview ¶
组件
Index ¶
- Constants
- func BuildApp(filePath string)
- func BuildApps(filePaths []string)
- func BuildComponent(fileName string)
- func BuildHandlerRotatorConfig(configPath string)
- func RegisterEntrances(entrances ...Entrance)
- func SetEntranceFactory(factory EntranceFactory)
- func SetHandlers(handlers ComponentHandlers)
- func SingleInstane(pidfile string)
- type App
- type AppConfig
- type CasperConfigs
- type Component
- type ComponentConfig
- type ComponentHandler
- type ComponentHandlers
- type ComponentMessage
- type ComponentMetadata
- type DefaultEntranceFactory
- type EndPoint
- type Entrance
- type EntranceConfig
- type EntranceFactory
- type EntranceMartini
- type EntranceMartiniConf
- type EntranceOptions
- type EntranceToContextConf
- type EntranceZMQ
- type Graphs
- type HandlerRotator
- type HttpResponse
- type MQChanMessenger
- func (p *MQChanMessenger) GetGraph(name string) []string
- func (p *MQChanMessenger) NewMessage(result interface{}) (msg *ComponentMessage, err error)
- func (p *MQChanMessenger) OnMessageEvent(msgId string, event MessageEvent)
- func (p *MQChanMessenger) ReceiveMessage(msg *ComponentMessage) (err error)
- func (p *MQChanMessenger) SendMessage(graphName string, comMsg *ComponentMessage) (msgId string, ch chan *Payload, err error)
- func (p *MQChanMessenger) SendToComponent(compMetadata *ComponentMetadata, msg []byte) (total int, err error)
- type MessageEvent
- type MessageQueue
- type Messenger
- type NameValue
- type Payload
- func (p *Payload) AppendCommand(command string, value interface{})
- func (p *Payload) GetCommand(key string) (val []interface{}, exist bool)
- func (p *Payload) GetCommandObjectArray(command string, values []interface{}) (err error)
- func (p *Payload) GetCommandStringArray(command string) (vals []string, err error)
- func (p *Payload) GetCommandValueSize(key string) int
- func (p *Payload) GetContext(key string) (val interface{}, exist bool)
- func (p *Payload) GetContextInt(key string) (val int, err error)
- func (p *Payload) GetContextInt32(key string) (val int32, err error)
- func (p *Payload) GetContextInt64(key string) (val int64, err error)
- func (p *Payload) GetContextObject(key string, v interface{}) (err error)
- func (p *Payload) GetContextString(key string) (val string, err error)
- func (p *Payload) GetContextStringArray(key string) (vals []string, err error)
- func (p *Payload) GetResult() interface{}
- func (p *Payload) SetCommand(command string, values []interface{})
- func (p *Payload) SetContext(key string, val interface{})
- func (p *Payload) SetResult(result interface{})
- func (p *Payload) UnmarshalResult(v interface{}) (err error)
- type RotatorParams
Constants ¶
View Source
const ( REQ_TIMEOUT = time.Duration(5) * time.Second REQ_X_API = "X-API" )
View Source
const ( CTX_HTTP_COOKIES = "CTX_HTTP_COOKIES" CTX_HTTP_HEADERS = "CTX_HTTP_HEADERS" CMD_HTTP_HEADERS_SET = "CMD_HTTP_HEADERS_SET" CMD_HTTP_COOKIES_SET = "CMD_HTTP_COOKIES_SET" )
View Source
const (
DefaultAPIHeader = "X-API"
)
Variables ¶
This section is empty.
Functions ¶
func BuildComponent ¶
func BuildComponent(fileName string)
func BuildHandlerRotatorConfig ¶
func BuildHandlerRotatorConfig(configPath string)
func RegisterEntrances ¶
func RegisterEntrances(entrances ...Entrance)
func SetEntranceFactory ¶
func SetEntranceFactory(factory EntranceFactory)
func SetHandlers ¶
func SetHandlers(handlers ComponentHandlers)
func SingleInstane ¶
func SingleInstane(pidfile string)
Types ¶
type App ¶
func GetAppByName ¶
type AppConfig ¶
type AppConfig struct { Name string `json:"name"` Description string `json:"description"` In string `json:"in"` MQType string `json:"mq_type"` Entrance EntranceOptions `json:"entrance"` Graphs map[string][]string `json:"graphs"` }
func (*AppConfig) ComponentConfig ¶
func (p *AppConfig) ComponentConfig() ComponentConfig
type CasperConfigs ¶
type CasperConfigs struct { Apps []AppConfig `json:"apps"` Components []ComponentConfig `json:"components"` }
type Component ¶
组件
func GetComponentByName ¶
func NewComponent ¶
func NewComponent(conf ComponentConfig) (component *Component, err error)
func NewComponentWithMessenger ¶
func NewComponentWithMessenger(conf ComponentConfig, messenger Messenger) (component *Component, err error)
func (*Component) GetComponentConfig ¶
func (p *Component) GetComponentConfig() ComponentConfig
func (*Component) Metadata ¶
func (p *Component) Metadata() ComponentMetadata
func (*Component) SendMsg ¶
func (p *Component) SendMsg(comMsg *ComponentMessage)
func (*Component) SetHandler ¶
func (p *Component) SetHandler(handler ComponentHandler) *Component
type ComponentConfig ¶
type ComponentConfig struct { Name string `json:"name"` Description string `json:"description"` MQType string `json:"mq_type"` In string `json:"in"` }
func (*ComponentConfig) Metadata ¶
func (p *ComponentConfig) Metadata() ComponentMetadata
type ComponentHandler ¶
type ComponentHandlers ¶
type ComponentHandlers map[string]ComponentHandler
type ComponentMessage ¶
type ComponentMessage struct { Id string `json:"id"` Payload *Payload `json:"payload"` // contains filtered or unexported fields }
func CallService ¶
func CallService(serviceType, addr string, msg *ComponentMessage) (reply *ComponentMessage, err error)
func NewComponentMessage ¶
func NewComponentMessage(entrance *ComponentMetadata, result interface{}) (msg *ComponentMessage, err error)
func (*ComponentMessage) FromJson ¶
func (p *ComponentMessage) FromJson(jsonStr []byte) (err error)
func (*ComponentMessage) PopGraph ¶
func (p *ComponentMessage) PopGraph() *ComponentMetadata
func (*ComponentMessage) Serialize ¶
func (p *ComponentMessage) Serialize() ([]byte, error)
func (*ComponentMessage) SetEntrance ¶
func (p *ComponentMessage) SetEntrance(entrance ComponentMetadata)
func (*ComponentMessage) TopGraph ¶
func (p *ComponentMessage) TopGraph() *ComponentMetadata
type ComponentMetadata ¶
type DefaultEntranceFactory ¶
type DefaultEntranceFactory struct {
// contains filtered or unexported fields
}
func NewDefaultEntranceFactory ¶
func NewDefaultEntranceFactory() *DefaultEntranceFactory
func (*DefaultEntranceFactory) NewEntrance ¶
func (p *DefaultEntranceFactory) NewEntrance(messengerr Messenger, typ string, configs EntranceConfig) Entrance
func (*DefaultEntranceFactory) RegisterEntrance ¶
func (p *DefaultEntranceFactory) RegisterEntrance(entrance Entrance)
type Entrance ¶
type Entrance interface { Type() string Init(messenger Messenger, configs EntranceConfig) error Run() error }
type EntranceConfig ¶
type EntranceConfig map[string]interface{}
func (EntranceConfig) FillToObject ¶
func (p EntranceConfig) FillToObject(v interface{}) (err error)
func (EntranceConfig) GetConfigString ¶
func (p EntranceConfig) GetConfigString(sectionName string) (value string, ok bool)
type EntranceFactory ¶
type EntranceFactory interface { RegisterEntrance(entrance Entrance) NewEntrance(messengerr Messenger, typ string, configs EntranceConfig) Entrance }
type EntranceMartini ¶
type EntranceMartini struct {
// contains filtered or unexported fields
}
func (*EntranceMartini) Init ¶
func (p *EntranceMartini) Init(messenger Messenger, configs EntranceConfig) (err error)
func (*EntranceMartini) Run ¶
func (p *EntranceMartini) Run() error
func (*EntranceMartini) Type ¶
func (p *EntranceMartini) Type() string
type EntranceMartiniConf ¶
type EntranceMartiniConf struct { Host string `json:"host"` Port int32 `json:"port"` Domain string `json:"domain"` Path string `json:"path"` AllowOrigin []string `json:"allow_origin"` AllowHeaders []string `json:"allow_headers"` P3P string `json:"p3p"` Server string `json:"server"` ToContext EntranceToContextConf `json:"to_context"` // contains filtered or unexported fields }
func (*EntranceMartiniConf) GetListenAddress ¶
func (p *EntranceMartiniConf) GetListenAddress() string
type EntranceOptions ¶
type EntranceOptions struct { Type string `json:"type"` Options EntranceConfig `json:"options"` }
type EntranceToContextConf ¶
type EntranceZMQ ¶
type EntranceZMQ struct {
// contains filtered or unexported fields
}
func (*EntranceZMQ) EntranceZMQHandler ¶
func (p *EntranceZMQ) EntranceZMQHandler()
func (*EntranceZMQ) Init ¶
func (p *EntranceZMQ) Init(messenger Messenger, configs EntranceConfig) (err error)
func (*EntranceZMQ) Run ¶
func (p *EntranceZMQ) Run() error
func (*EntranceZMQ) Type ¶
func (p *EntranceZMQ) Type() string
type HandlerRotator ¶
type HandlerRotator struct {
// contains filtered or unexported fields
}
func NewHandlerRotator ¶
func NewHandlerRotator(componentName string, handlers RotatorParams) (rotator *HandlerRotator)
func (*HandlerRotator) Handler ¶
func (p *HandlerRotator) Handler(payload *Payload) (interface{}, error)
func (*HandlerRotator) Rotate ¶
func (p *HandlerRotator) Rotate(name string) error
type HttpResponse ¶
type MQChanMessenger ¶
type MQChanMessenger struct {
// contains filtered or unexported fields
}
func NewMQChanMessenger ¶
func NewMQChanMessenger(graphs Graphs, compMetadata ComponentMetadata) *MQChanMessenger
func (*MQChanMessenger) GetGraph ¶
func (p *MQChanMessenger) GetGraph(name string) []string
func (*MQChanMessenger) NewMessage ¶
func (p *MQChanMessenger) NewMessage(result interface{}) (msg *ComponentMessage, err error)
func (*MQChanMessenger) OnMessageEvent ¶
func (p *MQChanMessenger) OnMessageEvent(msgId string, event MessageEvent)
func (*MQChanMessenger) ReceiveMessage ¶
func (p *MQChanMessenger) ReceiveMessage(msg *ComponentMessage) (err error)
func (*MQChanMessenger) SendMessage ¶
func (p *MQChanMessenger) SendMessage(graphName string, comMsg *ComponentMessage) (msgId string, ch chan *Payload, err error)
func (*MQChanMessenger) SendToComponent ¶
func (p *MQChanMessenger) SendToComponent(compMetadata *ComponentMetadata, msg []byte) (total int, err error)
type MessageQueue ¶
type MessageQueue interface { Ready() error // 初始化 RecvMessage() ([]byte, error) // 读一条消息 SendToNext([]byte) (int, error) // 发送一条消息到下一节点 }
消息接口
func NewMQ ¶
func NewMQ(compMeta *ComponentMetadata) (mq MessageQueue, err error)
func NewMqZmq ¶
func NewMqZmq(url string) MessageQueue
type Messenger ¶
type Messenger interface { NewMessage(result interface{}) (msg *ComponentMessage, err error) ReceiveMessage(msg *ComponentMessage) (err error) SendMessage(graphName string, comMsg *ComponentMessage) (msgId string, ch chan *Payload, err error) SendToComponent(compMetadata *ComponentMetadata, msg []byte) (total int, err error) OnMessageEvent(msgId string, event MessageEvent) }
type Payload ¶
type Payload struct { Code uint64 `json:"code"` Message string `json:"message"` // contains filtered or unexported fields }
func (*Payload) AppendCommand ¶
func (*Payload) GetCommand ¶
func (*Payload) GetCommandObjectArray ¶
func (*Payload) GetCommandStringArray ¶
func (*Payload) GetCommandValueSize ¶
func (*Payload) GetContext ¶
func (*Payload) GetContextInt32 ¶
func (*Payload) GetContextInt64 ¶
func (*Payload) GetContextObject ¶
func (*Payload) GetContextString ¶
func (*Payload) GetContextStringArray ¶
func (*Payload) SetCommand ¶
func (*Payload) SetContext ¶
func (*Payload) UnmarshalResult ¶
type RotatorParams ¶
type RotatorParams map[string]handler
Source Files ¶
Click to show internal directories.
Click to hide internal directories.