Documentation ¶
Index ¶
- Constants
- Variables
- func BlockToRequest(block model.TransferBlock) (request model.TransferRequest)
- func Execute(ctx context.Context, group *errgroup.Group, cfg *config.ListenAPI, ...) error
- func LedgerBlockToTransferBlock(channel string, block model.BlockData) map[model.ID]*model.TransferBlock
- type APIServer
- func (api *APIServer) TransferByAdmin(ctx context.Context, req *dto.TransferBeginAdminRequest) (*dto.TransferStatusResponse, error)
- func (api *APIServer) TransferByCustomer(ctx context.Context, req *dto.TransferBeginCustomerRequest) (*dto.TransferStatusResponse, error)
- func (api *APIServer) TransferStatus(ctx context.Context, req *dto.TransferStatusRequest) (*dto.TransferStatusResponse, error)
- type BlockCheckpoint
- type BlockController
- type CheckpointController
- type LedgerBlock
- type Request
- func (r *Request) IsChangeableStatus(status string) bool
- func (r *Request) Registry(ctx context.Context) ([]*model.TransferRequest, error)
- func (r *Request) TransferFetch(ctx context.Context, transfer model.ID) (model.TransferRequest, error)
- func (r *Request) TransferKeep(ctx context.Context, transferRequest model.TransferRequest) error
- func (r *Request) TransferModify(ctx context.Context, transferRequest model.TransferRequest, ttl time.Duration) error
- func (r *Request) TransferResultModify(ctx context.Context, transferID model.ID, result model.TransferResult) error
- type RequestController
Constants ¶
const StatusOptionFilterName = "excludeStatus"
Variables ¶
var ( ErrBadRequest = errors.New("bad request") ErrInvalidStatusCode = errors.New("invalid status code") ErrBadChannel = errors.New("channel not in configuration list") ErrPubKey = errors.New("public key of the signer of the request undefined") ErrNonce = errors.New("nonce undefined") ErrChaincode = errors.New("chaincode undefined") ErrMethod = errors.New("method name undefined") ErrUnknownMethod = errors.New("unknown method name") ErrSign = errors.New("sign undefined") )
Errors related to request processing.
Functions ¶
func BlockToRequest ¶
func BlockToRequest(block model.TransferBlock) (request model.TransferRequest)
func Execute ¶
func Execute( ctx context.Context, group *errgroup.Group, cfg *config.ListenAPI, channels []string, output chan model.TransferRequest, storage *redis.Storage, grpcMetrics *grpcprom.ServerMetrics, ) error
Execute - Run grpc and http server
Types ¶
type APIServer ¶
type APIServer struct { dto.UnimplementedAPIServer // contains filtered or unexported fields }
APIServer implements the logic for processing user requests and serves as the application server layer for working with the business logic of the app.
func NewAPIServer ¶
func NewAPIServer(ctx context.Context, output chan<- model.TransferRequest, ctrl RequestController, actualChannels []string) *APIServer
NewAPIServer creates a new instance of the structure with the specified controller.
func (*APIServer) TransferByAdmin ¶
func (api *APIServer) TransferByAdmin( ctx context.Context, req *dto.TransferBeginAdminRequest, ) (*dto.TransferStatusResponse, error)
TransferByAdmin registers a new transfer from one channel to another on behalf of the contract administrator, using business logic and maps the result to DTO request objects.
func (*APIServer) TransferByCustomer ¶
func (api *APIServer) TransferByCustomer( ctx context.Context, req *dto.TransferBeginCustomerRequest, ) (*dto.TransferStatusResponse, error)
TransferByCustomer registers a new transfer from one channel to another on behalf of the contract administrator, using business logic and maps the result to DTO request objects.
func (*APIServer) TransferStatus ¶
func (api *APIServer) TransferStatus( ctx context.Context, req *dto.TransferStatusRequest, ) (*dto.TransferStatusResponse, error)
TransferStatus returns the current status of the transfer. It requests the status from the business logic and maps it to DTO request objects.
type BlockCheckpoint ¶
type BlockCheckpoint struct {
// contains filtered or unexported fields
}
func NewBlockCheckpoint ¶
func NewBlockCheckpoint(storage *redis.Storage) *BlockCheckpoint
func (*BlockCheckpoint) CheckpointLoad ¶
func (ckp *BlockCheckpoint) CheckpointLoad(ctx context.Context, id model.ID) (model.Checkpoint, error)
func (*BlockCheckpoint) CheckpointSave ¶
func (ckp *BlockCheckpoint) CheckpointSave(ctx context.Context, checkpoint model.Checkpoint) (model.Checkpoint, error)
type BlockController ¶
type CheckpointController ¶
type CheckpointController interface { // CheckpointSave saves the checkpoint of the processed data of the ledger channel. CheckpointSave(context.Context, model.Checkpoint) (model.Checkpoint, error) // CheckpointLoad retrieves the checkpoint of the processed data of the ledger channel. CheckpointLoad(context.Context, model.ID) (model.Checkpoint, error) }
type LedgerBlock ¶
type LedgerBlock struct {
// contains filtered or unexported fields
}
func NewLedgerBlock ¶
func NewLedgerBlock(storage *redis.Storage) *LedgerBlock
func (*LedgerBlock) BlockLoad ¶
func (lb *LedgerBlock) BlockLoad(ctx context.Context, id model.ID) (model.TransferBlock, error)
func (*LedgerBlock) BlockSave ¶
func (lb *LedgerBlock) BlockSave(ctx context.Context, transferBlock model.TransferBlock, ttl time.Duration) error
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func NewRequest ¶
func (*Request) IsChangeableStatus ¶
func (*Request) TransferFetch ¶
func (*Request) TransferKeep ¶
func (*Request) TransferModify ¶
func (*Request) TransferResultModify ¶
type RequestController ¶
type RequestController interface { // TransferKeep storage a request to transfer funds from one channel to // another. TransferKeep(context.Context, model.TransferRequest) error // TransferFetch retrieves the transfer by ID with updated status and the // result of processing the transfer request. TransferFetch(context.Context, model.ID) (model.TransferRequest, error) }
RequestController is responsible for implementing the processing of user and administrator requests to perform transfer operations from one channel to another.