Documentation ¶
Index ¶
- Constants
- type Caller
- type CallerPlugin
- type CallerRPC
- type CallerRPCServer
- func (c *CallerRPCServer) Commit(req RpcReqComponent, resp *RpcResComponent) error
- func (c *CallerRPCServer) Execute(req RpcReqComponent, resp *RpcResComponent) error
- func (c *CallerRPCServer) Prepare(req RpcReqComponent, resp *RpcResComponent) error
- func (c *CallerRPCServer) Rollback(req RpcReqComponent, resp *RpcResComponent) error
- type Component
- func (component *Component) Commit(config []byte, input []byte, output []byte, context Context) ([]byte, error)
- func (component *Component) Execute(config []byte, input []byte, context Context) ([]byte, error)
- func (component *Component) Prepare(config []byte, input []byte, context Context) ([]byte, error)
- func (component *Component) Rollback(config []byte, input []byte, output []byte, context Context) ([]byte, error)
- type ComponentFileInfo
- type Context
- type DiskInfo
- type FTPInfo
- type Handler
- type MinIOInfo
- type RpcComponentContext
- type RpcReqComponent
- type RpcResComponent
Constants ¶
const ( DefaultComponentName = "default" MagicCookieKey = "BASIC_PLUGIN" MagicCookieValue = "ipaas-go-component" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Caller ¶
type Caller interface { Execute(request RpcReqComponent) RpcResComponent Prepare(request RpcReqComponent) RpcResComponent Rollback(request RpcReqComponent) RpcResComponent Commit(request RpcReqComponent) RpcResComponent }
Caller is the interface that we're exposing as a plugin.
type CallerPlugin ¶
type CallerPlugin struct { // Impl Injection Impl Caller }
This is the implementation of plugin.Plugin so we can serve/consume this
This has two methods: Server must return an RPC server for this plugin type. We construct a GreeterRPCServer for this.
Client must return an implementation of our interface that communicates over an RPC client. We return GreeterRPC for this.
Ignore MuxBroker. That is used to create more multiplexed streams on our plugin connection and is a more advanced use case.
func (CallerPlugin) Client ¶
func (CallerPlugin) Client(b *plugin.MuxBroker, c *rpc.Client) (interface{}, error)
func (*CallerPlugin) Server ¶
func (p *CallerPlugin) Server(*plugin.MuxBroker) (interface{}, error)
type CallerRPC ¶
type CallerRPC struct {
// contains filtered or unexported fields
}
Here is an implementation that talks over RPC
func (*CallerRPC) Commit ¶
func (c *CallerRPC) Commit(request RpcReqComponent) RpcResComponent
func (*CallerRPC) Execute ¶
func (c *CallerRPC) Execute(request RpcReqComponent) RpcResComponent
func (*CallerRPC) Prepare ¶
func (c *CallerRPC) Prepare(request RpcReqComponent) RpcResComponent
func (*CallerRPC) Rollback ¶
func (c *CallerRPC) Rollback(request RpcReqComponent) RpcResComponent
type CallerRPCServer ¶
type CallerRPCServer struct { // This is the real implementation Impl Caller }
Here is the RPC server that GreeterRPC talks to, conforming to the requirements of net/rpc
func (*CallerRPCServer) Commit ¶
func (c *CallerRPCServer) Commit(req RpcReqComponent, resp *RpcResComponent) error
func (*CallerRPCServer) Execute ¶
func (c *CallerRPCServer) Execute(req RpcReqComponent, resp *RpcResComponent) error
func (*CallerRPCServer) Prepare ¶
func (c *CallerRPCServer) Prepare(req RpcReqComponent, resp *RpcResComponent) error
func (*CallerRPCServer) Rollback ¶
func (c *CallerRPCServer) Rollback(req RpcReqComponent, resp *RpcResComponent) error
type Component ¶
type Component struct { FileClient fileClient // contains filtered or unexported fields }
func NewComponent ¶
func NewComponent(executeHandler interface{}, prepareHandler interface{}, commitHandler interface{}, rollbackHandler interface{}) *Component
NewFunction which creates a Function with a given Handler
func (*Component) Commit ¶
func (component *Component) Commit(config []byte, input []byte, output []byte, context Context) ([]byte, error)
*
- 组件事务提交
type ComponentFileInfo ¶ added in v1.1.0
type Context ¶
type Context struct { /** * 子组件名称 */ Name string `json:"name"` /** * 子组件版本 */ Version string `json:"version"` /** * 设置事务ID, commit和rollback可以获取使用 */ TransactionId string `json:"transactionId"` /** * 请求id,用于链路追踪 */ RequestId string `json:"requestId"` Logger hclog.Logger FileClient fileClient }
type Handler ¶
type Handler interface { /** * 执行逻辑 */ Invoke(config []byte, input []byte, output []byte, context Context) ([]byte, error) }
func NewCommitAndRollbackHandler ¶
func NewCommitAndRollbackHandler(handlerFunc interface{}) Handler
NewHandler creates a base fc component from the given handler function. The returned Handler performs JSON serialization and deserialization, and delegates to the input handler function. The handler function parameter must satisfy the rules documented by Start. If handlerFunc is not a valid handler, the returned Handler simply reports the validation error.
func NewExecuteAndPrepareHandler ¶
func NewExecuteAndPrepareHandler(handlerFunc interface{}) Handler
NewHandler creates a base fc component from the given handler function. The returned Handler performs JSON serialization and deserialization, and delegates to the input handler function. The handler function parameter must satisfy the rules documented by Start. If handlerFunc is not a valid handler, the returned Handler simply reports the validation error.
type RpcComponentContext ¶
type RpcReqComponent ¶
type RpcReqComponent struct { Config []byte `json:"config"` Input []byte `json:"input"` Output []byte `json:"output"` ComponentContext RpcComponentContext `json:"componentContext"` }