2022-10-31 10:49:21 +00:00
|
|
|
package operations
|
|
|
|
|
|
|
|
import (
|
2023-04-21 06:49:17 +00:00
|
|
|
. "github.com/reiver/greatape/components/api/protobuf"
|
|
|
|
. "github.com/reiver/greatape/components/api/services"
|
|
|
|
. "github.com/reiver/greatape/components/contracts"
|
2022-10-31 10:49:21 +00:00
|
|
|
. "github.com/xeronith/diamante/contracts/operation"
|
|
|
|
. "github.com/xeronith/diamante/contracts/service"
|
|
|
|
. "github.com/xeronith/diamante/contracts/system"
|
|
|
|
. "github.com/xeronith/diamante/operation"
|
|
|
|
)
|
|
|
|
|
2023-06-26 07:50:54 +00:00
|
|
|
type (
|
|
|
|
SystemCallRunner func(IContext, *SystemCallRequest) (*SystemCallResult, error)
|
|
|
|
SystemCallRunners []SystemCallRunner
|
2022-10-31 10:49:21 +00:00
|
|
|
|
2023-06-26 07:50:54 +00:00
|
|
|
systemCallOperation struct {
|
|
|
|
AdminOperation
|
|
|
|
|
|
|
|
runners SystemCallRunners
|
|
|
|
}
|
|
|
|
)
|
2022-10-31 10:49:21 +00:00
|
|
|
|
|
|
|
func SystemCallOperation() IOperation {
|
|
|
|
return &systemCallOperation{
|
2023-06-26 07:50:54 +00:00
|
|
|
runners: SystemCallRunners{
|
|
|
|
SystemCallService,
|
|
|
|
},
|
2022-10-31 10:49:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-26 07:50:54 +00:00
|
|
|
func (operation *systemCallOperation) Tag() string {
|
|
|
|
return "SYSTEM_CALL"
|
|
|
|
}
|
|
|
|
|
2022-10-31 10:49:21 +00:00
|
|
|
func (operation *systemCallOperation) Id() (ID, ID) {
|
|
|
|
return SYSTEM_CALL_REQUEST, SYSTEM_CALL_RESULT
|
|
|
|
}
|
|
|
|
|
|
|
|
func (operation *systemCallOperation) InputContainer() Pointer {
|
|
|
|
return new(SystemCallRequest)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (operation *systemCallOperation) OutputContainer() Pointer {
|
|
|
|
return new(SystemCallResult)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (operation *systemCallOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
2023-06-26 07:50:54 +00:00
|
|
|
return operation.runners[0](context, payload.(*SystemCallRequest))
|
2022-10-31 10:49:21 +00:00
|
|
|
}
|