kopia lustrzana https://github.com/reiver/greatape
feat(components): ⚡ implement multi runner operations
rodzic
ae874ce9db
commit
ea5083def7
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type authorizeInteractionOperation struct {
|
||||
Operation
|
||||
type (
|
||||
AuthorizeInteractionRunner func(IContext, *AuthorizeInteractionRequest) (*AuthorizeInteractionResult, error)
|
||||
AuthorizeInteractionRunners []AuthorizeInteractionRunner
|
||||
|
||||
run func(IContext, *AuthorizeInteractionRequest) (*AuthorizeInteractionResult, error)
|
||||
}
|
||||
authorizeInteractionOperation struct {
|
||||
Operation
|
||||
|
||||
runners AuthorizeInteractionRunners
|
||||
}
|
||||
)
|
||||
|
||||
func AuthorizeInteractionOperation() IOperation {
|
||||
return &authorizeInteractionOperation{
|
||||
run: AuthorizeInteractionService,
|
||||
runners: AuthorizeInteractionRunners{
|
||||
AuthorizeInteractionService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *authorizeInteractionOperation) Tag() string {
|
||||
return "AUTHORIZE_INTERACTION"
|
||||
}
|
||||
|
||||
func (operation *authorizeInteractionOperation) Id() (ID, ID) {
|
||||
return AUTHORIZE_INTERACTION_REQUEST, AUTHORIZE_INTERACTION_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *authorizeInteractionOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *authorizeInteractionOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*AuthorizeInteractionRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*AuthorizeInteractionRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type changePasswordOperation struct {
|
||||
SecureOperation
|
||||
type (
|
||||
ChangePasswordRunner func(IContext, *ChangePasswordRequest) (*ChangePasswordResult, error)
|
||||
ChangePasswordRunners []ChangePasswordRunner
|
||||
|
||||
run func(IContext, *ChangePasswordRequest) (*ChangePasswordResult, error)
|
||||
}
|
||||
changePasswordOperation struct {
|
||||
SecureOperation
|
||||
|
||||
runners ChangePasswordRunners
|
||||
}
|
||||
)
|
||||
|
||||
func ChangePasswordOperation() IOperation {
|
||||
return &changePasswordOperation{
|
||||
run: ChangePasswordService,
|
||||
runners: ChangePasswordRunners{
|
||||
ChangePasswordService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *changePasswordOperation) Tag() string {
|
||||
return "CHANGE_PASSWORD"
|
||||
}
|
||||
|
||||
func (operation *changePasswordOperation) Id() (ID, ID) {
|
||||
return CHANGE_PASSWORD_REQUEST, CHANGE_PASSWORD_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *changePasswordOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *changePasswordOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*ChangePasswordRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*ChangePasswordRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type checkUsernameAvailabilityOperation struct {
|
||||
Operation
|
||||
type (
|
||||
CheckUsernameAvailabilityRunner func(IContext, *CheckUsernameAvailabilityRequest) (*CheckUsernameAvailabilityResult, error)
|
||||
CheckUsernameAvailabilityRunners []CheckUsernameAvailabilityRunner
|
||||
|
||||
run func(IContext, *CheckUsernameAvailabilityRequest) (*CheckUsernameAvailabilityResult, error)
|
||||
}
|
||||
checkUsernameAvailabilityOperation struct {
|
||||
Operation
|
||||
|
||||
runners CheckUsernameAvailabilityRunners
|
||||
}
|
||||
)
|
||||
|
||||
func CheckUsernameAvailabilityOperation() IOperation {
|
||||
return &checkUsernameAvailabilityOperation{
|
||||
run: CheckUsernameAvailabilityService,
|
||||
runners: CheckUsernameAvailabilityRunners{
|
||||
CheckUsernameAvailabilityService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *checkUsernameAvailabilityOperation) Tag() string {
|
||||
return "CHECK_USERNAME_AVAILABILITY"
|
||||
}
|
||||
|
||||
func (operation *checkUsernameAvailabilityOperation) Id() (ID, ID) {
|
||||
return CHECK_USERNAME_AVAILABILITY_REQUEST, CHECK_USERNAME_AVAILABILITY_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *checkUsernameAvailabilityOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *checkUsernameAvailabilityOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*CheckUsernameAvailabilityRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*CheckUsernameAvailabilityRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type echoOperation struct {
|
||||
Operation
|
||||
type (
|
||||
EchoRunner func(IContext, *EchoRequest) (*EchoResult, error)
|
||||
EchoRunners []EchoRunner
|
||||
|
||||
run func(IContext, *EchoRequest) (*EchoResult, error)
|
||||
}
|
||||
echoOperation struct {
|
||||
Operation
|
||||
|
||||
runners EchoRunners
|
||||
}
|
||||
)
|
||||
|
||||
func EchoOperation() IOperation {
|
||||
return &echoOperation{
|
||||
run: EchoService,
|
||||
runners: EchoRunners{
|
||||
EchoService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *echoOperation) Tag() string {
|
||||
return "ECHO"
|
||||
}
|
||||
|
||||
func (operation *echoOperation) Id() (ID, ID) {
|
||||
return ECHO_REQUEST, ECHO_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *echoOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *echoOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*EchoRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*EchoRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type followActorOperation struct {
|
||||
Operation
|
||||
type (
|
||||
FollowActorRunner func(IContext, *FollowActorRequest) (*FollowActorResult, error)
|
||||
FollowActorRunners []FollowActorRunner
|
||||
|
||||
run func(IContext, *FollowActorRequest) (*FollowActorResult, error)
|
||||
}
|
||||
followActorOperation struct {
|
||||
Operation
|
||||
|
||||
runners FollowActorRunners
|
||||
}
|
||||
)
|
||||
|
||||
func FollowActorOperation() IOperation {
|
||||
return &followActorOperation{
|
||||
run: FollowActorService,
|
||||
runners: FollowActorRunners{
|
||||
FollowActorService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *followActorOperation) Tag() string {
|
||||
return "FOLLOW_ACTOR"
|
||||
}
|
||||
|
||||
func (operation *followActorOperation) Id() (ID, ID) {
|
||||
return FOLLOW_ACTOR_REQUEST, FOLLOW_ACTOR_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *followActorOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *followActorOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*FollowActorRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*FollowActorRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type getActorOperation struct {
|
||||
Operation
|
||||
type (
|
||||
GetActorRunner func(IContext, *GetActorRequest) (*GetActorResult, error)
|
||||
GetActorRunners []GetActorRunner
|
||||
|
||||
run func(IContext, *GetActorRequest) (*GetActorResult, error)
|
||||
}
|
||||
getActorOperation struct {
|
||||
Operation
|
||||
|
||||
runners GetActorRunners
|
||||
}
|
||||
)
|
||||
|
||||
func GetActorOperation() IOperation {
|
||||
return &getActorOperation{
|
||||
run: GetActorService,
|
||||
runners: GetActorRunners{
|
||||
GetActorService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *getActorOperation) Tag() string {
|
||||
return "GET_ACTOR"
|
||||
}
|
||||
|
||||
func (operation *getActorOperation) Id() (ID, ID) {
|
||||
return GET_ACTOR_REQUEST, GET_ACTOR_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *getActorOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *getActorOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*GetActorRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*GetActorRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type getFollowersOperation struct {
|
||||
Operation
|
||||
type (
|
||||
GetFollowersRunner func(IContext, *GetFollowersRequest) (*GetFollowersResult, error)
|
||||
GetFollowersRunners []GetFollowersRunner
|
||||
|
||||
run func(IContext, *GetFollowersRequest) (*GetFollowersResult, error)
|
||||
}
|
||||
getFollowersOperation struct {
|
||||
Operation
|
||||
|
||||
runners GetFollowersRunners
|
||||
}
|
||||
)
|
||||
|
||||
func GetFollowersOperation() IOperation {
|
||||
return &getFollowersOperation{
|
||||
run: GetFollowersService,
|
||||
runners: GetFollowersRunners{
|
||||
GetFollowersService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *getFollowersOperation) Tag() string {
|
||||
return "GET_FOLLOWERS"
|
||||
}
|
||||
|
||||
func (operation *getFollowersOperation) Id() (ID, ID) {
|
||||
return GET_FOLLOWERS_REQUEST, GET_FOLLOWERS_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *getFollowersOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *getFollowersOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*GetFollowersRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*GetFollowersRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type getFollowingOperation struct {
|
||||
Operation
|
||||
type (
|
||||
GetFollowingRunner func(IContext, *GetFollowingRequest) (*GetFollowingResult, error)
|
||||
GetFollowingRunners []GetFollowingRunner
|
||||
|
||||
run func(IContext, *GetFollowingRequest) (*GetFollowingResult, error)
|
||||
}
|
||||
getFollowingOperation struct {
|
||||
Operation
|
||||
|
||||
runners GetFollowingRunners
|
||||
}
|
||||
)
|
||||
|
||||
func GetFollowingOperation() IOperation {
|
||||
return &getFollowingOperation{
|
||||
run: GetFollowingService,
|
||||
runners: GetFollowingRunners{
|
||||
GetFollowingService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *getFollowingOperation) Tag() string {
|
||||
return "GET_FOLLOWING"
|
||||
}
|
||||
|
||||
func (operation *getFollowingOperation) Id() (ID, ID) {
|
||||
return GET_FOLLOWING_REQUEST, GET_FOLLOWING_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *getFollowingOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *getFollowingOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*GetFollowingRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*GetFollowingRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type getInboxOperation struct {
|
||||
Operation
|
||||
type (
|
||||
GetInboxRunner func(IContext, *GetInboxRequest) (*GetInboxResult, error)
|
||||
GetInboxRunners []GetInboxRunner
|
||||
|
||||
run func(IContext, *GetInboxRequest) (*GetInboxResult, error)
|
||||
}
|
||||
getInboxOperation struct {
|
||||
Operation
|
||||
|
||||
runners GetInboxRunners
|
||||
}
|
||||
)
|
||||
|
||||
func GetInboxOperation() IOperation {
|
||||
return &getInboxOperation{
|
||||
run: GetInboxService,
|
||||
runners: GetInboxRunners{
|
||||
GetInboxService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *getInboxOperation) Tag() string {
|
||||
return "GET_INBOX"
|
||||
}
|
||||
|
||||
func (operation *getInboxOperation) Id() (ID, ID) {
|
||||
return GET_INBOX_REQUEST, GET_INBOX_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *getInboxOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *getInboxOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*GetInboxRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*GetInboxRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type getOutboxOperation struct {
|
||||
Operation
|
||||
type (
|
||||
GetOutboxRunner func(IContext, *GetOutboxRequest) (*GetOutboxResult, error)
|
||||
GetOutboxRunners []GetOutboxRunner
|
||||
|
||||
run func(IContext, *GetOutboxRequest) (*GetOutboxResult, error)
|
||||
}
|
||||
getOutboxOperation struct {
|
||||
Operation
|
||||
|
||||
runners GetOutboxRunners
|
||||
}
|
||||
)
|
||||
|
||||
func GetOutboxOperation() IOperation {
|
||||
return &getOutboxOperation{
|
||||
run: GetOutboxService,
|
||||
runners: GetOutboxRunners{
|
||||
GetOutboxService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *getOutboxOperation) Tag() string {
|
||||
return "GET_OUTBOX"
|
||||
}
|
||||
|
||||
func (operation *getOutboxOperation) Id() (ID, ID) {
|
||||
return GET_OUTBOX_REQUEST, GET_OUTBOX_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *getOutboxOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *getOutboxOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*GetOutboxRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*GetOutboxRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type getPackagesOperation struct {
|
||||
Operation
|
||||
type (
|
||||
GetPackagesRunner func(IContext, *GetPackagesRequest) (*GetPackagesResult, error)
|
||||
GetPackagesRunners []GetPackagesRunner
|
||||
|
||||
run func(IContext, *GetPackagesRequest) (*GetPackagesResult, error)
|
||||
}
|
||||
getPackagesOperation struct {
|
||||
Operation
|
||||
|
||||
runners GetPackagesRunners
|
||||
}
|
||||
)
|
||||
|
||||
func GetPackagesOperation() IOperation {
|
||||
return &getPackagesOperation{
|
||||
run: GetPackagesService,
|
||||
runners: GetPackagesRunners{
|
||||
GetPackagesService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *getPackagesOperation) Tag() string {
|
||||
return "GET_PACKAGES"
|
||||
}
|
||||
|
||||
func (operation *getPackagesOperation) Id() (ID, ID) {
|
||||
return GET_PACKAGES_REQUEST, GET_PACKAGES_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *getPackagesOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *getPackagesOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*GetPackagesRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*GetPackagesRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type getProfileByUserOperation struct {
|
||||
SecureOperation
|
||||
type (
|
||||
GetProfileByUserRunner func(IContext, *GetProfileByUserRequest) (*GetProfileByUserResult, error)
|
||||
GetProfileByUserRunners []GetProfileByUserRunner
|
||||
|
||||
run func(IContext, *GetProfileByUserRequest) (*GetProfileByUserResult, error)
|
||||
}
|
||||
getProfileByUserOperation struct {
|
||||
SecureOperation
|
||||
|
||||
runners GetProfileByUserRunners
|
||||
}
|
||||
)
|
||||
|
||||
func GetProfileByUserOperation() IOperation {
|
||||
return &getProfileByUserOperation{
|
||||
run: GetProfileByUserService,
|
||||
runners: GetProfileByUserRunners{
|
||||
GetProfileByUserService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *getProfileByUserOperation) Tag() string {
|
||||
return "GET_PROFILE_BY_USER"
|
||||
}
|
||||
|
||||
func (operation *getProfileByUserOperation) Id() (ID, ID) {
|
||||
return GET_PROFILE_BY_USER_REQUEST, GET_PROFILE_BY_USER_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *getProfileByUserOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *getProfileByUserOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*GetProfileByUserRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*GetProfileByUserRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type getServerConfigurationOperation struct {
|
||||
Operation
|
||||
type (
|
||||
GetServerConfigurationRunner func(IContext, *GetServerConfigurationRequest) (*GetServerConfigurationResult, error)
|
||||
GetServerConfigurationRunners []GetServerConfigurationRunner
|
||||
|
||||
run func(IContext, *GetServerConfigurationRequest) (*GetServerConfigurationResult, error)
|
||||
}
|
||||
getServerConfigurationOperation struct {
|
||||
Operation
|
||||
|
||||
runners GetServerConfigurationRunners
|
||||
}
|
||||
)
|
||||
|
||||
func GetServerConfigurationOperation() IOperation {
|
||||
return &getServerConfigurationOperation{
|
||||
run: GetServerConfigurationService,
|
||||
runners: GetServerConfigurationRunners{
|
||||
GetServerConfigurationService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *getServerConfigurationOperation) Tag() string {
|
||||
return "GET_SERVER_CONFIGURATION"
|
||||
}
|
||||
|
||||
func (operation *getServerConfigurationOperation) Id() (ID, ID) {
|
||||
return GET_SERVER_CONFIGURATION_REQUEST, GET_SERVER_CONFIGURATION_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *getServerConfigurationOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *getServerConfigurationOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*GetServerConfigurationRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*GetServerConfigurationRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type loginOperation struct {
|
||||
Operation
|
||||
type (
|
||||
LoginRunner func(IContext, *LoginRequest) (*LoginResult, error)
|
||||
LoginRunners []LoginRunner
|
||||
|
||||
run func(IContext, *LoginRequest) (*LoginResult, error)
|
||||
}
|
||||
loginOperation struct {
|
||||
Operation
|
||||
|
||||
runners LoginRunners
|
||||
}
|
||||
)
|
||||
|
||||
func LoginOperation() IOperation {
|
||||
return &loginOperation{
|
||||
run: LoginService,
|
||||
runners: LoginRunners{
|
||||
LoginService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *loginOperation) Tag() string {
|
||||
return "LOGIN"
|
||||
}
|
||||
|
||||
func (operation *loginOperation) Id() (ID, ID) {
|
||||
return LOGIN_REQUEST, LOGIN_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *loginOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *loginOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*LoginRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*LoginRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type logoutOperation struct {
|
||||
SecureOperation
|
||||
type (
|
||||
LogoutRunner func(IContext, *LogoutRequest) (*LogoutResult, error)
|
||||
LogoutRunners []LogoutRunner
|
||||
|
||||
run func(IContext, *LogoutRequest) (*LogoutResult, error)
|
||||
}
|
||||
logoutOperation struct {
|
||||
SecureOperation
|
||||
|
||||
runners LogoutRunners
|
||||
}
|
||||
)
|
||||
|
||||
func LogoutOperation() IOperation {
|
||||
return &logoutOperation{
|
||||
run: LogoutService,
|
||||
runners: LogoutRunners{
|
||||
LogoutService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *logoutOperation) Tag() string {
|
||||
return "LOGOUT"
|
||||
}
|
||||
|
||||
func (operation *logoutOperation) Id() (ID, ID) {
|
||||
return LOGOUT_REQUEST, LOGOUT_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *logoutOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *logoutOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*LogoutRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*LogoutRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type postToInboxOperation struct {
|
||||
Operation
|
||||
type (
|
||||
PostToInboxRunner func(IContext, *PostToInboxRequest) (*PostToInboxResult, error)
|
||||
PostToInboxRunners []PostToInboxRunner
|
||||
|
||||
run func(IContext, *PostToInboxRequest) (*PostToInboxResult, error)
|
||||
}
|
||||
postToInboxOperation struct {
|
||||
Operation
|
||||
|
||||
runners PostToInboxRunners
|
||||
}
|
||||
)
|
||||
|
||||
func PostToInboxOperation() IOperation {
|
||||
return &postToInboxOperation{
|
||||
run: PostToInboxService,
|
||||
runners: PostToInboxRunners{
|
||||
PostToInboxService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *postToInboxOperation) Tag() string {
|
||||
return "POST_TO_INBOX"
|
||||
}
|
||||
|
||||
func (operation *postToInboxOperation) Id() (ID, ID) {
|
||||
return POST_TO_INBOX_REQUEST, POST_TO_INBOX_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *postToInboxOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *postToInboxOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*PostToInboxRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*PostToInboxRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type postToOutboxOperation struct {
|
||||
Operation
|
||||
type (
|
||||
PostToOutboxRunner func(IContext, *PostToOutboxRequest) (*PostToOutboxResult, error)
|
||||
PostToOutboxRunners []PostToOutboxRunner
|
||||
|
||||
run func(IContext, *PostToOutboxRequest) (*PostToOutboxResult, error)
|
||||
}
|
||||
postToOutboxOperation struct {
|
||||
Operation
|
||||
|
||||
runners PostToOutboxRunners
|
||||
}
|
||||
)
|
||||
|
||||
func PostToOutboxOperation() IOperation {
|
||||
return &postToOutboxOperation{
|
||||
run: PostToOutboxService,
|
||||
runners: PostToOutboxRunners{
|
||||
PostToOutboxService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *postToOutboxOperation) Tag() string {
|
||||
return "POST_TO_OUTBOX"
|
||||
}
|
||||
|
||||
func (operation *postToOutboxOperation) Id() (ID, ID) {
|
||||
return POST_TO_OUTBOX_REQUEST, POST_TO_OUTBOX_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *postToOutboxOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *postToOutboxOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*PostToOutboxRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*PostToOutboxRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type resendVerificationCodeOperation struct {
|
||||
Operation
|
||||
type (
|
||||
ResendVerificationCodeRunner func(IContext, *ResendVerificationCodeRequest) (*ResendVerificationCodeResult, error)
|
||||
ResendVerificationCodeRunners []ResendVerificationCodeRunner
|
||||
|
||||
run func(IContext, *ResendVerificationCodeRequest) (*ResendVerificationCodeResult, error)
|
||||
}
|
||||
resendVerificationCodeOperation struct {
|
||||
Operation
|
||||
|
||||
runners ResendVerificationCodeRunners
|
||||
}
|
||||
)
|
||||
|
||||
func ResendVerificationCodeOperation() IOperation {
|
||||
return &resendVerificationCodeOperation{
|
||||
run: ResendVerificationCodeService,
|
||||
runners: ResendVerificationCodeRunners{
|
||||
ResendVerificationCodeService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *resendVerificationCodeOperation) Tag() string {
|
||||
return "RESEND_VERIFICATION_CODE"
|
||||
}
|
||||
|
||||
func (operation *resendVerificationCodeOperation) Id() (ID, ID) {
|
||||
return RESEND_VERIFICATION_CODE_REQUEST, RESEND_VERIFICATION_CODE_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *resendVerificationCodeOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *resendVerificationCodeOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*ResendVerificationCodeRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*ResendVerificationCodeRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type resetPasswordOperation struct {
|
||||
Operation
|
||||
type (
|
||||
ResetPasswordRunner func(IContext, *ResetPasswordRequest) (*ResetPasswordResult, error)
|
||||
ResetPasswordRunners []ResetPasswordRunner
|
||||
|
||||
run func(IContext, *ResetPasswordRequest) (*ResetPasswordResult, error)
|
||||
}
|
||||
resetPasswordOperation struct {
|
||||
Operation
|
||||
|
||||
runners ResetPasswordRunners
|
||||
}
|
||||
)
|
||||
|
||||
func ResetPasswordOperation() IOperation {
|
||||
return &resetPasswordOperation{
|
||||
run: ResetPasswordService,
|
||||
runners: ResetPasswordRunners{
|
||||
ResetPasswordService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *resetPasswordOperation) Tag() string {
|
||||
return "RESET_PASSWORD"
|
||||
}
|
||||
|
||||
func (operation *resetPasswordOperation) Id() (ID, ID) {
|
||||
return RESET_PASSWORD_REQUEST, RESET_PASSWORD_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *resetPasswordOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *resetPasswordOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*ResetPasswordRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*ResetPasswordRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type signupOperation struct {
|
||||
Operation
|
||||
type (
|
||||
SignupRunner func(IContext, *SignupRequest) (*SignupResult, error)
|
||||
SignupRunners []SignupRunner
|
||||
|
||||
run func(IContext, *SignupRequest) (*SignupResult, error)
|
||||
}
|
||||
signupOperation struct {
|
||||
Operation
|
||||
|
||||
runners SignupRunners
|
||||
}
|
||||
)
|
||||
|
||||
func SignupOperation() IOperation {
|
||||
return &signupOperation{
|
||||
run: SignupService,
|
||||
runners: SignupRunners{
|
||||
SignupService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *signupOperation) Tag() string {
|
||||
return "SIGNUP"
|
||||
}
|
||||
|
||||
func (operation *signupOperation) Id() (ID, ID) {
|
||||
return SIGNUP_REQUEST, SIGNUP_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *signupOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *signupOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*SignupRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*SignupRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
|
@ -10,18 +10,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type systemCallOperation struct {
|
||||
AdminOperation
|
||||
type (
|
||||
SystemCallRunner func(IContext, *SystemCallRequest) (*SystemCallResult, error)
|
||||
SystemCallRunners []SystemCallRunner
|
||||
|
||||
run func(IContext, *SystemCallRequest) (*SystemCallResult, error)
|
||||
}
|
||||
systemCallOperation struct {
|
||||
AdminOperation
|
||||
|
||||
runners SystemCallRunners
|
||||
}
|
||||
)
|
||||
|
||||
func SystemCallOperation() IOperation {
|
||||
return &systemCallOperation{
|
||||
run: SystemCallService,
|
||||
runners: SystemCallRunners{
|
||||
SystemCallService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *systemCallOperation) Tag() string {
|
||||
return "SYSTEM_CALL"
|
||||
}
|
||||
|
||||
func (operation *systemCallOperation) Id() (ID, ID) {
|
||||
return SYSTEM_CALL_REQUEST, SYSTEM_CALL_RESULT
|
||||
}
|
||||
|
@ -35,5 +46,5 @@ func (operation *systemCallOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *systemCallOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*SystemCallRequest))
|
||||
return operation.runners[0](context, payload.(*SystemCallRequest))
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type updateProfileByUserOperation struct {
|
||||
SecureOperation
|
||||
type (
|
||||
UpdateProfileByUserRunner func(IContext, *UpdateProfileByUserRequest) (*UpdateProfileByUserResult, error)
|
||||
UpdateProfileByUserRunners []UpdateProfileByUserRunner
|
||||
|
||||
run func(IContext, *UpdateProfileByUserRequest) (*UpdateProfileByUserResult, error)
|
||||
}
|
||||
updateProfileByUserOperation struct {
|
||||
SecureOperation
|
||||
|
||||
runners UpdateProfileByUserRunners
|
||||
}
|
||||
)
|
||||
|
||||
func UpdateProfileByUserOperation() IOperation {
|
||||
return &updateProfileByUserOperation{
|
||||
run: UpdateProfileByUserService,
|
||||
runners: UpdateProfileByUserRunners{
|
||||
UpdateProfileByUserService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *updateProfileByUserOperation) Tag() string {
|
||||
return "UPDATE_PROFILE_BY_USER"
|
||||
}
|
||||
|
||||
func (operation *updateProfileByUserOperation) Id() (ID, ID) {
|
||||
return UPDATE_PROFILE_BY_USER_REQUEST, UPDATE_PROFILE_BY_USER_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *updateProfileByUserOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *updateProfileByUserOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*UpdateProfileByUserRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*UpdateProfileByUserRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type verifyOperation struct {
|
||||
Operation
|
||||
type (
|
||||
VerifyRunner func(IContext, *VerifyRequest) (*VerifyResult, error)
|
||||
VerifyRunners []VerifyRunner
|
||||
|
||||
run func(IContext, *VerifyRequest) (*VerifyResult, error)
|
||||
}
|
||||
verifyOperation struct {
|
||||
Operation
|
||||
|
||||
runners VerifyRunners
|
||||
}
|
||||
)
|
||||
|
||||
func VerifyOperation() IOperation {
|
||||
return &verifyOperation{
|
||||
run: VerifyService,
|
||||
runners: VerifyRunners{
|
||||
VerifyService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *verifyOperation) Tag() string {
|
||||
return "VERIFY"
|
||||
}
|
||||
|
||||
func (operation *verifyOperation) Id() (ID, ID) {
|
||||
return VERIFY_REQUEST, VERIFY_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *verifyOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *verifyOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*VerifyRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*VerifyRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package operations
|
|||
import (
|
||||
. "github.com/reiver/greatape/components/api/protobuf"
|
||||
. "github.com/reiver/greatape/components/api/services"
|
||||
. "github.com/reiver/greatape/components/constants"
|
||||
. "github.com/reiver/greatape/components/contracts"
|
||||
. "github.com/xeronith/diamante/contracts/operation"
|
||||
. "github.com/xeronith/diamante/contracts/service"
|
||||
|
@ -10,18 +11,29 @@ import (
|
|||
. "github.com/xeronith/diamante/operation"
|
||||
)
|
||||
|
||||
type webfingerOperation struct {
|
||||
Operation
|
||||
type (
|
||||
WebfingerRunner func(IContext, *WebfingerRequest) (*WebfingerResult, error)
|
||||
WebfingerRunners []WebfingerRunner
|
||||
|
||||
run func(IContext, *WebfingerRequest) (*WebfingerResult, error)
|
||||
}
|
||||
webfingerOperation struct {
|
||||
Operation
|
||||
|
||||
runners WebfingerRunners
|
||||
}
|
||||
)
|
||||
|
||||
func WebfingerOperation() IOperation {
|
||||
return &webfingerOperation{
|
||||
run: WebfingerService,
|
||||
runners: WebfingerRunners{
|
||||
WebfingerService,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (operation *webfingerOperation) Tag() string {
|
||||
return "WEBFINGER"
|
||||
}
|
||||
|
||||
func (operation *webfingerOperation) Id() (ID, ID) {
|
||||
return WEBFINGER_REQUEST, WEBFINGER_RESULT
|
||||
}
|
||||
|
@ -35,5 +47,14 @@ func (operation *webfingerOperation) OutputContainer() Pointer {
|
|||
}
|
||||
|
||||
func (operation *webfingerOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
|
||||
return operation.run(context, payload.(*WebfingerRequest))
|
||||
if len(operation.runners) <= int(operation.ActiveRunner()) {
|
||||
return nil, ERROR_OPERATION_RUNNER_NOT_AVAILABLE
|
||||
}
|
||||
|
||||
service := operation.runners[operation.ActiveRunner()]
|
||||
if input, valid := payload.(*WebfingerRequest); valid {
|
||||
return service(context, input)
|
||||
}
|
||||
|
||||
return nil, ERROR_OPERATION_PAYLOAD_NOT_SUPPORTED
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue