feat(components): implement multi runner operations

master
Xeronith 2023-06-26 11:20:54 +03:30
rodzic ae874ce9db
commit ea5083def7
24 zmienionych plików z 638 dodań i 144 usunięć

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type authorizeInteractionOperation struct { type (
Operation AuthorizeInteractionRunner func(IContext, *AuthorizeInteractionRequest) (*AuthorizeInteractionResult, error)
AuthorizeInteractionRunners []AuthorizeInteractionRunner
run func(IContext, *AuthorizeInteractionRequest) (*AuthorizeInteractionResult, error) authorizeInteractionOperation struct {
} Operation
runners AuthorizeInteractionRunners
}
)
func AuthorizeInteractionOperation() IOperation { func AuthorizeInteractionOperation() IOperation {
return &authorizeInteractionOperation{ return &authorizeInteractionOperation{
run: AuthorizeInteractionService, runners: AuthorizeInteractionRunners{
AuthorizeInteractionService,
},
} }
} }
func (operation *authorizeInteractionOperation) Tag() string {
return "AUTHORIZE_INTERACTION"
}
func (operation *authorizeInteractionOperation) Id() (ID, ID) { func (operation *authorizeInteractionOperation) Id() (ID, ID) {
return AUTHORIZE_INTERACTION_REQUEST, AUTHORIZE_INTERACTION_RESULT 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) { 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
} }

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type changePasswordOperation struct { type (
SecureOperation ChangePasswordRunner func(IContext, *ChangePasswordRequest) (*ChangePasswordResult, error)
ChangePasswordRunners []ChangePasswordRunner
run func(IContext, *ChangePasswordRequest) (*ChangePasswordResult, error) changePasswordOperation struct {
} SecureOperation
runners ChangePasswordRunners
}
)
func ChangePasswordOperation() IOperation { func ChangePasswordOperation() IOperation {
return &changePasswordOperation{ return &changePasswordOperation{
run: ChangePasswordService, runners: ChangePasswordRunners{
ChangePasswordService,
},
} }
} }
func (operation *changePasswordOperation) Tag() string {
return "CHANGE_PASSWORD"
}
func (operation *changePasswordOperation) Id() (ID, ID) { func (operation *changePasswordOperation) Id() (ID, ID) {
return CHANGE_PASSWORD_REQUEST, CHANGE_PASSWORD_RESULT 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) { 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
} }

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type checkUsernameAvailabilityOperation struct { type (
Operation CheckUsernameAvailabilityRunner func(IContext, *CheckUsernameAvailabilityRequest) (*CheckUsernameAvailabilityResult, error)
CheckUsernameAvailabilityRunners []CheckUsernameAvailabilityRunner
run func(IContext, *CheckUsernameAvailabilityRequest) (*CheckUsernameAvailabilityResult, error) checkUsernameAvailabilityOperation struct {
} Operation
runners CheckUsernameAvailabilityRunners
}
)
func CheckUsernameAvailabilityOperation() IOperation { func CheckUsernameAvailabilityOperation() IOperation {
return &checkUsernameAvailabilityOperation{ return &checkUsernameAvailabilityOperation{
run: CheckUsernameAvailabilityService, runners: CheckUsernameAvailabilityRunners{
CheckUsernameAvailabilityService,
},
} }
} }
func (operation *checkUsernameAvailabilityOperation) Tag() string {
return "CHECK_USERNAME_AVAILABILITY"
}
func (operation *checkUsernameAvailabilityOperation) Id() (ID, ID) { func (operation *checkUsernameAvailabilityOperation) Id() (ID, ID) {
return CHECK_USERNAME_AVAILABILITY_REQUEST, CHECK_USERNAME_AVAILABILITY_RESULT 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) { 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
} }

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type echoOperation struct { type (
Operation EchoRunner func(IContext, *EchoRequest) (*EchoResult, error)
EchoRunners []EchoRunner
run func(IContext, *EchoRequest) (*EchoResult, error) echoOperation struct {
} Operation
runners EchoRunners
}
)
func EchoOperation() IOperation { func EchoOperation() IOperation {
return &echoOperation{ return &echoOperation{
run: EchoService, runners: EchoRunners{
EchoService,
},
} }
} }
func (operation *echoOperation) Tag() string {
return "ECHO"
}
func (operation *echoOperation) Id() (ID, ID) { func (operation *echoOperation) Id() (ID, ID) {
return ECHO_REQUEST, ECHO_RESULT return ECHO_REQUEST, ECHO_RESULT
} }
@ -35,5 +47,14 @@ func (operation *echoOperation) OutputContainer() Pointer {
} }
func (operation *echoOperation) Execute(context IContext, payload Pointer) (Pointer, error) { 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
} }

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type followActorOperation struct { type (
Operation FollowActorRunner func(IContext, *FollowActorRequest) (*FollowActorResult, error)
FollowActorRunners []FollowActorRunner
run func(IContext, *FollowActorRequest) (*FollowActorResult, error) followActorOperation struct {
} Operation
runners FollowActorRunners
}
)
func FollowActorOperation() IOperation { func FollowActorOperation() IOperation {
return &followActorOperation{ return &followActorOperation{
run: FollowActorService, runners: FollowActorRunners{
FollowActorService,
},
} }
} }
func (operation *followActorOperation) Tag() string {
return "FOLLOW_ACTOR"
}
func (operation *followActorOperation) Id() (ID, ID) { func (operation *followActorOperation) Id() (ID, ID) {
return FOLLOW_ACTOR_REQUEST, FOLLOW_ACTOR_RESULT 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) { 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
} }

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type getActorOperation struct { type (
Operation GetActorRunner func(IContext, *GetActorRequest) (*GetActorResult, error)
GetActorRunners []GetActorRunner
run func(IContext, *GetActorRequest) (*GetActorResult, error) getActorOperation struct {
} Operation
runners GetActorRunners
}
)
func GetActorOperation() IOperation { func GetActorOperation() IOperation {
return &getActorOperation{ return &getActorOperation{
run: GetActorService, runners: GetActorRunners{
GetActorService,
},
} }
} }
func (operation *getActorOperation) Tag() string {
return "GET_ACTOR"
}
func (operation *getActorOperation) Id() (ID, ID) { func (operation *getActorOperation) Id() (ID, ID) {
return GET_ACTOR_REQUEST, GET_ACTOR_RESULT 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) { 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
} }

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type getFollowersOperation struct { type (
Operation GetFollowersRunner func(IContext, *GetFollowersRequest) (*GetFollowersResult, error)
GetFollowersRunners []GetFollowersRunner
run func(IContext, *GetFollowersRequest) (*GetFollowersResult, error) getFollowersOperation struct {
} Operation
runners GetFollowersRunners
}
)
func GetFollowersOperation() IOperation { func GetFollowersOperation() IOperation {
return &getFollowersOperation{ return &getFollowersOperation{
run: GetFollowersService, runners: GetFollowersRunners{
GetFollowersService,
},
} }
} }
func (operation *getFollowersOperation) Tag() string {
return "GET_FOLLOWERS"
}
func (operation *getFollowersOperation) Id() (ID, ID) { func (operation *getFollowersOperation) Id() (ID, ID) {
return GET_FOLLOWERS_REQUEST, GET_FOLLOWERS_RESULT 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) { 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
} }

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type getFollowingOperation struct { type (
Operation GetFollowingRunner func(IContext, *GetFollowingRequest) (*GetFollowingResult, error)
GetFollowingRunners []GetFollowingRunner
run func(IContext, *GetFollowingRequest) (*GetFollowingResult, error) getFollowingOperation struct {
} Operation
runners GetFollowingRunners
}
)
func GetFollowingOperation() IOperation { func GetFollowingOperation() IOperation {
return &getFollowingOperation{ return &getFollowingOperation{
run: GetFollowingService, runners: GetFollowingRunners{
GetFollowingService,
},
} }
} }
func (operation *getFollowingOperation) Tag() string {
return "GET_FOLLOWING"
}
func (operation *getFollowingOperation) Id() (ID, ID) { func (operation *getFollowingOperation) Id() (ID, ID) {
return GET_FOLLOWING_REQUEST, GET_FOLLOWING_RESULT 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) { 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
} }

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type getInboxOperation struct { type (
Operation GetInboxRunner func(IContext, *GetInboxRequest) (*GetInboxResult, error)
GetInboxRunners []GetInboxRunner
run func(IContext, *GetInboxRequest) (*GetInboxResult, error) getInboxOperation struct {
} Operation
runners GetInboxRunners
}
)
func GetInboxOperation() IOperation { func GetInboxOperation() IOperation {
return &getInboxOperation{ return &getInboxOperation{
run: GetInboxService, runners: GetInboxRunners{
GetInboxService,
},
} }
} }
func (operation *getInboxOperation) Tag() string {
return "GET_INBOX"
}
func (operation *getInboxOperation) Id() (ID, ID) { func (operation *getInboxOperation) Id() (ID, ID) {
return GET_INBOX_REQUEST, GET_INBOX_RESULT 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) { 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
} }

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type getOutboxOperation struct { type (
Operation GetOutboxRunner func(IContext, *GetOutboxRequest) (*GetOutboxResult, error)
GetOutboxRunners []GetOutboxRunner
run func(IContext, *GetOutboxRequest) (*GetOutboxResult, error) getOutboxOperation struct {
} Operation
runners GetOutboxRunners
}
)
func GetOutboxOperation() IOperation { func GetOutboxOperation() IOperation {
return &getOutboxOperation{ return &getOutboxOperation{
run: GetOutboxService, runners: GetOutboxRunners{
GetOutboxService,
},
} }
} }
func (operation *getOutboxOperation) Tag() string {
return "GET_OUTBOX"
}
func (operation *getOutboxOperation) Id() (ID, ID) { func (operation *getOutboxOperation) Id() (ID, ID) {
return GET_OUTBOX_REQUEST, GET_OUTBOX_RESULT 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) { 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
} }

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type getPackagesOperation struct { type (
Operation GetPackagesRunner func(IContext, *GetPackagesRequest) (*GetPackagesResult, error)
GetPackagesRunners []GetPackagesRunner
run func(IContext, *GetPackagesRequest) (*GetPackagesResult, error) getPackagesOperation struct {
} Operation
runners GetPackagesRunners
}
)
func GetPackagesOperation() IOperation { func GetPackagesOperation() IOperation {
return &getPackagesOperation{ return &getPackagesOperation{
run: GetPackagesService, runners: GetPackagesRunners{
GetPackagesService,
},
} }
} }
func (operation *getPackagesOperation) Tag() string {
return "GET_PACKAGES"
}
func (operation *getPackagesOperation) Id() (ID, ID) { func (operation *getPackagesOperation) Id() (ID, ID) {
return GET_PACKAGES_REQUEST, GET_PACKAGES_RESULT 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) { 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
} }

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type getProfileByUserOperation struct { type (
SecureOperation GetProfileByUserRunner func(IContext, *GetProfileByUserRequest) (*GetProfileByUserResult, error)
GetProfileByUserRunners []GetProfileByUserRunner
run func(IContext, *GetProfileByUserRequest) (*GetProfileByUserResult, error) getProfileByUserOperation struct {
} SecureOperation
runners GetProfileByUserRunners
}
)
func GetProfileByUserOperation() IOperation { func GetProfileByUserOperation() IOperation {
return &getProfileByUserOperation{ return &getProfileByUserOperation{
run: GetProfileByUserService, runners: GetProfileByUserRunners{
GetProfileByUserService,
},
} }
} }
func (operation *getProfileByUserOperation) Tag() string {
return "GET_PROFILE_BY_USER"
}
func (operation *getProfileByUserOperation) Id() (ID, ID) { func (operation *getProfileByUserOperation) Id() (ID, ID) {
return GET_PROFILE_BY_USER_REQUEST, GET_PROFILE_BY_USER_RESULT 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) { 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
} }

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type getServerConfigurationOperation struct { type (
Operation GetServerConfigurationRunner func(IContext, *GetServerConfigurationRequest) (*GetServerConfigurationResult, error)
GetServerConfigurationRunners []GetServerConfigurationRunner
run func(IContext, *GetServerConfigurationRequest) (*GetServerConfigurationResult, error) getServerConfigurationOperation struct {
} Operation
runners GetServerConfigurationRunners
}
)
func GetServerConfigurationOperation() IOperation { func GetServerConfigurationOperation() IOperation {
return &getServerConfigurationOperation{ return &getServerConfigurationOperation{
run: GetServerConfigurationService, runners: GetServerConfigurationRunners{
GetServerConfigurationService,
},
} }
} }
func (operation *getServerConfigurationOperation) Tag() string {
return "GET_SERVER_CONFIGURATION"
}
func (operation *getServerConfigurationOperation) Id() (ID, ID) { func (operation *getServerConfigurationOperation) Id() (ID, ID) {
return GET_SERVER_CONFIGURATION_REQUEST, GET_SERVER_CONFIGURATION_RESULT 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) { 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
} }

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type loginOperation struct { type (
Operation LoginRunner func(IContext, *LoginRequest) (*LoginResult, error)
LoginRunners []LoginRunner
run func(IContext, *LoginRequest) (*LoginResult, error) loginOperation struct {
} Operation
runners LoginRunners
}
)
func LoginOperation() IOperation { func LoginOperation() IOperation {
return &loginOperation{ return &loginOperation{
run: LoginService, runners: LoginRunners{
LoginService,
},
} }
} }
func (operation *loginOperation) Tag() string {
return "LOGIN"
}
func (operation *loginOperation) Id() (ID, ID) { func (operation *loginOperation) Id() (ID, ID) {
return LOGIN_REQUEST, LOGIN_RESULT return LOGIN_REQUEST, LOGIN_RESULT
} }
@ -35,5 +47,14 @@ func (operation *loginOperation) OutputContainer() Pointer {
} }
func (operation *loginOperation) Execute(context IContext, payload Pointer) (Pointer, error) { 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
} }

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type logoutOperation struct { type (
SecureOperation LogoutRunner func(IContext, *LogoutRequest) (*LogoutResult, error)
LogoutRunners []LogoutRunner
run func(IContext, *LogoutRequest) (*LogoutResult, error) logoutOperation struct {
} SecureOperation
runners LogoutRunners
}
)
func LogoutOperation() IOperation { func LogoutOperation() IOperation {
return &logoutOperation{ return &logoutOperation{
run: LogoutService, runners: LogoutRunners{
LogoutService,
},
} }
} }
func (operation *logoutOperation) Tag() string {
return "LOGOUT"
}
func (operation *logoutOperation) Id() (ID, ID) { func (operation *logoutOperation) Id() (ID, ID) {
return LOGOUT_REQUEST, LOGOUT_RESULT return LOGOUT_REQUEST, LOGOUT_RESULT
} }
@ -35,5 +47,14 @@ func (operation *logoutOperation) OutputContainer() Pointer {
} }
func (operation *logoutOperation) Execute(context IContext, payload Pointer) (Pointer, error) { 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
} }

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type postToInboxOperation struct { type (
Operation PostToInboxRunner func(IContext, *PostToInboxRequest) (*PostToInboxResult, error)
PostToInboxRunners []PostToInboxRunner
run func(IContext, *PostToInboxRequest) (*PostToInboxResult, error) postToInboxOperation struct {
} Operation
runners PostToInboxRunners
}
)
func PostToInboxOperation() IOperation { func PostToInboxOperation() IOperation {
return &postToInboxOperation{ return &postToInboxOperation{
run: PostToInboxService, runners: PostToInboxRunners{
PostToInboxService,
},
} }
} }
func (operation *postToInboxOperation) Tag() string {
return "POST_TO_INBOX"
}
func (operation *postToInboxOperation) Id() (ID, ID) { func (operation *postToInboxOperation) Id() (ID, ID) {
return POST_TO_INBOX_REQUEST, POST_TO_INBOX_RESULT 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) { 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
} }

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type postToOutboxOperation struct { type (
Operation PostToOutboxRunner func(IContext, *PostToOutboxRequest) (*PostToOutboxResult, error)
PostToOutboxRunners []PostToOutboxRunner
run func(IContext, *PostToOutboxRequest) (*PostToOutboxResult, error) postToOutboxOperation struct {
} Operation
runners PostToOutboxRunners
}
)
func PostToOutboxOperation() IOperation { func PostToOutboxOperation() IOperation {
return &postToOutboxOperation{ return &postToOutboxOperation{
run: PostToOutboxService, runners: PostToOutboxRunners{
PostToOutboxService,
},
} }
} }
func (operation *postToOutboxOperation) Tag() string {
return "POST_TO_OUTBOX"
}
func (operation *postToOutboxOperation) Id() (ID, ID) { func (operation *postToOutboxOperation) Id() (ID, ID) {
return POST_TO_OUTBOX_REQUEST, POST_TO_OUTBOX_RESULT 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) { 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
} }

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type resendVerificationCodeOperation struct { type (
Operation ResendVerificationCodeRunner func(IContext, *ResendVerificationCodeRequest) (*ResendVerificationCodeResult, error)
ResendVerificationCodeRunners []ResendVerificationCodeRunner
run func(IContext, *ResendVerificationCodeRequest) (*ResendVerificationCodeResult, error) resendVerificationCodeOperation struct {
} Operation
runners ResendVerificationCodeRunners
}
)
func ResendVerificationCodeOperation() IOperation { func ResendVerificationCodeOperation() IOperation {
return &resendVerificationCodeOperation{ return &resendVerificationCodeOperation{
run: ResendVerificationCodeService, runners: ResendVerificationCodeRunners{
ResendVerificationCodeService,
},
} }
} }
func (operation *resendVerificationCodeOperation) Tag() string {
return "RESEND_VERIFICATION_CODE"
}
func (operation *resendVerificationCodeOperation) Id() (ID, ID) { func (operation *resendVerificationCodeOperation) Id() (ID, ID) {
return RESEND_VERIFICATION_CODE_REQUEST, RESEND_VERIFICATION_CODE_RESULT 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) { 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
} }

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type resetPasswordOperation struct { type (
Operation ResetPasswordRunner func(IContext, *ResetPasswordRequest) (*ResetPasswordResult, error)
ResetPasswordRunners []ResetPasswordRunner
run func(IContext, *ResetPasswordRequest) (*ResetPasswordResult, error) resetPasswordOperation struct {
} Operation
runners ResetPasswordRunners
}
)
func ResetPasswordOperation() IOperation { func ResetPasswordOperation() IOperation {
return &resetPasswordOperation{ return &resetPasswordOperation{
run: ResetPasswordService, runners: ResetPasswordRunners{
ResetPasswordService,
},
} }
} }
func (operation *resetPasswordOperation) Tag() string {
return "RESET_PASSWORD"
}
func (operation *resetPasswordOperation) Id() (ID, ID) { func (operation *resetPasswordOperation) Id() (ID, ID) {
return RESET_PASSWORD_REQUEST, RESET_PASSWORD_RESULT 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) { 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
} }

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type signupOperation struct { type (
Operation SignupRunner func(IContext, *SignupRequest) (*SignupResult, error)
SignupRunners []SignupRunner
run func(IContext, *SignupRequest) (*SignupResult, error) signupOperation struct {
} Operation
runners SignupRunners
}
)
func SignupOperation() IOperation { func SignupOperation() IOperation {
return &signupOperation{ return &signupOperation{
run: SignupService, runners: SignupRunners{
SignupService,
},
} }
} }
func (operation *signupOperation) Tag() string {
return "SIGNUP"
}
func (operation *signupOperation) Id() (ID, ID) { func (operation *signupOperation) Id() (ID, ID) {
return SIGNUP_REQUEST, SIGNUP_RESULT return SIGNUP_REQUEST, SIGNUP_RESULT
} }
@ -35,5 +47,14 @@ func (operation *signupOperation) OutputContainer() Pointer {
} }
func (operation *signupOperation) Execute(context IContext, payload Pointer) (Pointer, error) { 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
} }

Wyświetl plik

@ -10,18 +10,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type systemCallOperation struct { type (
AdminOperation SystemCallRunner func(IContext, *SystemCallRequest) (*SystemCallResult, error)
SystemCallRunners []SystemCallRunner
run func(IContext, *SystemCallRequest) (*SystemCallResult, error) systemCallOperation struct {
} AdminOperation
runners SystemCallRunners
}
)
func SystemCallOperation() IOperation { func SystemCallOperation() IOperation {
return &systemCallOperation{ return &systemCallOperation{
run: SystemCallService, runners: SystemCallRunners{
SystemCallService,
},
} }
} }
func (operation *systemCallOperation) Tag() string {
return "SYSTEM_CALL"
}
func (operation *systemCallOperation) Id() (ID, ID) { func (operation *systemCallOperation) Id() (ID, ID) {
return SYSTEM_CALL_REQUEST, SYSTEM_CALL_RESULT 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) { func (operation *systemCallOperation) Execute(context IContext, payload Pointer) (Pointer, error) {
return operation.run(context, payload.(*SystemCallRequest)) return operation.runners[0](context, payload.(*SystemCallRequest))
} }

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type updateProfileByUserOperation struct { type (
SecureOperation UpdateProfileByUserRunner func(IContext, *UpdateProfileByUserRequest) (*UpdateProfileByUserResult, error)
UpdateProfileByUserRunners []UpdateProfileByUserRunner
run func(IContext, *UpdateProfileByUserRequest) (*UpdateProfileByUserResult, error) updateProfileByUserOperation struct {
} SecureOperation
runners UpdateProfileByUserRunners
}
)
func UpdateProfileByUserOperation() IOperation { func UpdateProfileByUserOperation() IOperation {
return &updateProfileByUserOperation{ return &updateProfileByUserOperation{
run: UpdateProfileByUserService, runners: UpdateProfileByUserRunners{
UpdateProfileByUserService,
},
} }
} }
func (operation *updateProfileByUserOperation) Tag() string {
return "UPDATE_PROFILE_BY_USER"
}
func (operation *updateProfileByUserOperation) Id() (ID, ID) { func (operation *updateProfileByUserOperation) Id() (ID, ID) {
return UPDATE_PROFILE_BY_USER_REQUEST, UPDATE_PROFILE_BY_USER_RESULT 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) { 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
} }

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type verifyOperation struct { type (
Operation VerifyRunner func(IContext, *VerifyRequest) (*VerifyResult, error)
VerifyRunners []VerifyRunner
run func(IContext, *VerifyRequest) (*VerifyResult, error) verifyOperation struct {
} Operation
runners VerifyRunners
}
)
func VerifyOperation() IOperation { func VerifyOperation() IOperation {
return &verifyOperation{ return &verifyOperation{
run: VerifyService, runners: VerifyRunners{
VerifyService,
},
} }
} }
func (operation *verifyOperation) Tag() string {
return "VERIFY"
}
func (operation *verifyOperation) Id() (ID, ID) { func (operation *verifyOperation) Id() (ID, ID) {
return VERIFY_REQUEST, VERIFY_RESULT return VERIFY_REQUEST, VERIFY_RESULT
} }
@ -35,5 +47,14 @@ func (operation *verifyOperation) OutputContainer() Pointer {
} }
func (operation *verifyOperation) Execute(context IContext, payload Pointer) (Pointer, error) { 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
} }

Wyświetl plik

@ -3,6 +3,7 @@ package operations
import ( import (
. "github.com/reiver/greatape/components/api/protobuf" . "github.com/reiver/greatape/components/api/protobuf"
. "github.com/reiver/greatape/components/api/services" . "github.com/reiver/greatape/components/api/services"
. "github.com/reiver/greatape/components/constants"
. "github.com/reiver/greatape/components/contracts" . "github.com/reiver/greatape/components/contracts"
. "github.com/xeronith/diamante/contracts/operation" . "github.com/xeronith/diamante/contracts/operation"
. "github.com/xeronith/diamante/contracts/service" . "github.com/xeronith/diamante/contracts/service"
@ -10,18 +11,29 @@ import (
. "github.com/xeronith/diamante/operation" . "github.com/xeronith/diamante/operation"
) )
type webfingerOperation struct { type (
Operation WebfingerRunner func(IContext, *WebfingerRequest) (*WebfingerResult, error)
WebfingerRunners []WebfingerRunner
run func(IContext, *WebfingerRequest) (*WebfingerResult, error) webfingerOperation struct {
} Operation
runners WebfingerRunners
}
)
func WebfingerOperation() IOperation { func WebfingerOperation() IOperation {
return &webfingerOperation{ return &webfingerOperation{
run: WebfingerService, runners: WebfingerRunners{
WebfingerService,
},
} }
} }
func (operation *webfingerOperation) Tag() string {
return "WEBFINGER"
}
func (operation *webfingerOperation) Id() (ID, ID) { func (operation *webfingerOperation) Id() (ID, ID) {
return WEBFINGER_REQUEST, WEBFINGER_RESULT return WEBFINGER_REQUEST, WEBFINGER_RESULT
} }
@ -35,5 +47,14 @@ func (operation *webfingerOperation) OutputContainer() Pointer {
} }
func (operation *webfingerOperation) Execute(context IContext, payload Pointer) (Pointer, error) { 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
} }