Skip to main content

Generated from package comments and exported declarations. Edit the Go source, not this file.

idempotency

import "codeberg.org/hemanta212/playgo/api/idempotency"

Package idempotency defines shared keys, records, and resource references for safe retries.

Idempotency is what stops one intention from being carried out twice. An admin clicks "approve", the network drops the response, they click again - without protection, that is two payouts. With it, the second request returns the result of the first.

A key is bound to the actor, the operation, a hash of the request, its processing status, and the durable result. Implementations should return the stored result when the same request has already completed, an in-progress conflict while the work is still running, and a conflict when the same key arrives with different input. That last case is a genuine bug in the caller: a key identifies one specific request, not a session or a user.

Constants​

const ProviderHealthKeyPrefix = "provider-health:"

Variables​

var (
ErrMissingKey = errors.New("idempotency: missing key")
ErrConflict = errors.New("idempotency: key reused with different command")
ErrInProgress = errors.New("idempotency: operation in progress")
)

type BeginOutcome​

type BeginOutcome string
const (
BeginOutcomeStarted BeginOutcome = "started"
BeginOutcomeReplay BeginOutcome = "replay"
BeginOutcomeInProgress BeginOutcome = "in_progress"
BeginOutcomeConflict BeginOutcome = "conflict"
)

type Input​

type Input struct {
ActorID uuid.UUID
Key *Key
}

type Key​

type Key struct {
// contains filtered or unexported fields
}

func MustKey​

func MustKey(value string) Key

func NewKey​

func NewKey(value string) (Key, error)

func (Key) String​

func (k Key) String() string

type Operation​

type Operation string
const (
OperationStorePlayerLinkPreview Operation = "store_player_link_preview"
OperationStorePlayerLink Operation = "store_player_link"
)
const (
OperationStorePlayerPasswordAccess Operation = "store_player_password_access"
OperationAdminProviderAccountPasswordAccess Operation = "admin_provider_account_password_access"
)
const (
OperationStoreRosterRefresh Operation = "store_roster_refresh"
OperationStorePlayerLookup Operation = "store_player_lookup"
OperationStorePlayerPanelPassword Operation = "store_player_panel_password"
)
const (
OperationWalletCredit Operation = "wallet_credit"
OperationSignupPreferences Operation = "signup_preferences"
OperationWalletDebit Operation = "wallet_debit"
OperationAdminWalletAdjustment Operation = "admin_wallet_adjustment"
OperationPaymentDepositCreate Operation = "payment_deposit_create"
OperationPaymentOffAppDepositCreate Operation = "payment_off_app_deposit_create"
OperationPaymentOffAppDepositUpdate Operation = "payment_off_app_deposit_update"
OperationPaymentOffAppDepositSettle Operation = "payment_off_app_deposit_settle"
OperationPaymentOffAppDepositVoid Operation = "payment_off_app_deposit_void"
OperationPaymentOffAppDepositReverse Operation = "payment_off_app_deposit_reverse"
OperationPaymentOffAppProofInitiate Operation = "payment_off_app_deposit_proof_initiate"
OperationPaymentOffAppProofFinalize Operation = "payment_off_app_deposit_proof_finalize"
OperationPaymentOffAppDepositConvert Operation = "payment_off_app_deposit_convert"
OperationPaymentWithdrawalCreate Operation = "payment_withdrawal_create"
OperationPaymentWithdrawalApprove Operation = "payment_withdrawal_approve"
OperationPaymentWithdrawalReject Operation = "payment_withdrawal_reject"
OperationPaymentWithdrawalCancel Operation = "payment_withdrawal_cancel"
OperationPaymentWithdrawalMarkPaid Operation = "payment_withdrawal_mark_paid"
OperationPaymentWithdrawalFailed Operation = "payment_withdrawal_confirm_failed"
OperationPaymentWithdrawalExpire Operation = "payment_withdrawal_expire"
OperationPaymentWithdrawalRelease Operation = "payment_withdrawal_provider_release"
OperationPaymentWithdrawalSettle Operation = "payment_withdrawal_provider_settle"
OperationProviderLoadReserve Operation = "provider_load_reserve"
OperationProviderLoadRefund Operation = "provider_load_refund"
OperationAdminProviderLoadResolve Operation = "admin_provider_load_resolve"
OperationProviderCashoutSettle Operation = "provider_cashout_settle"
OperationProviderBonusOnlyCloseLoss Operation = "provider_bonus_only_close_loss"
OperationGameLaunch Operation = "game_launch"
OperationGameResetPassword Operation = "game_reset_password"
OperationGameAdd Operation = "game_add"
OperationSupportPlayerMessageSend Operation = "support_player_message_send"
OperationSupportAdminMessageSend Operation = "support_admin_message_send"
OperationSupportConversationResolve Operation = "support_conversation_resolve"
OperationSupportConversationReopen Operation = "support_conversation_reopen"
OperationPaymentMethodRemove Operation = "payment_method_remove"
OperationProviderAccountLink Operation = "provider_account_link"
OperationAdminProviderAccountLink Operation = "admin_provider_account_link"
OperationAdminProviderAccountUnlink Operation = "admin_provider_account_unlink"
OperationAdminProviderAccountPanelPassword Operation = "admin_provider_account_panel_password"
OperationAdminProviderAccountLinkRetry Operation = "admin_provider_account_link_retry"
OperationAdminProviderAccountUnlinkPreview Operation = "admin_provider_account_unlink_preview"
OperationAdminProviderAccountUnlinkPreviewCancel Operation = "admin_provider_account_unlink_preview_cancel"
OperationProviderAccountReconnect Operation = "provider_account_reconnect"
OperationAdminProviderAccountSetPassword Operation = "admin_provider_account_set_password"
OperationAdminProviderAccountResetPassword Operation = "admin_provider_account_reset_password"
OperationAdminProviderAccountRecheck Operation = "admin_provider_account_recheck"
OperationAdminProviderAccountRelink Operation = "admin_provider_account_relink"
OperationFirstUnloadReviewCancel Operation = "provider_first_unload_review_cancel"
OperationAdminFirstUnloadApprove Operation = "admin_first_unload_review_approve"
OperationAdminFirstUnloadReject Operation = "admin_first_unload_review_reject"
OperationAdminFirstUnloadResolve Operation = "admin_first_unload_review_resolve"
OperationProviderReviewedUnloadSettle Operation = "provider_reviewed_unload_settle"
)
const (
OperationStoreAgentPreview Operation = "store_agent_preview"
OperationStoreAgentTransfer Operation = "store_agent_transfer"
OperationStoreAgentResolution Operation = "store_agent_resolution"
)
const OperationStoreCreateResolution Operation = "store_create_resolution"
const OperationStorePlayerCreate Operation = "store_player_create"
const OperationStorePlayerPasswordReset Operation = "store_player_password_reset"

type Record​

type Record struct {
ID uuid.UUID
ActorID uuid.UUID
Operation Operation
Key Key
RequestHash RequestHash
Status Status
ResultJSON []byte
Resource *ResourceRef
}

type RequestHash​

type RequestHash [sha256.Size]byte

type ResourceRef​

type ResourceRef struct {
Type ResourceType
ID uuid.UUID
}

type ResourceType​

type ResourceType string
const (
ResourceTypeStoreRosterRefresh ResourceType = "store_roster_refresh"
ResourceTypeStorePlayerLookup ResourceType = "store_player_lookup"
ResourceTypeStorePlayerManagement ResourceType = "store_player_management"
)
const (
ResourceTypeLedgerTransaction ResourceType = "ledger_transaction"
ResourceTypePaymentIntent ResourceType = "payment_intent"
ResourceTypePaymentWithdrawalIntent ResourceType = "payment_withdrawal_intent"
ResourceTypeSupportMessage ResourceType = "support_message"
ResourceTypeSupportConversation ResourceType = "support_conversation"
ResourceTypePaymentMethod ResourceType = "payment_method"
ResourceTypeAdminWalletAdjustment ResourceType = "admin_wallet_adjustment"
ResourceTypeProviderAccount ResourceType = "provider_account"
ResourceTypeFirstUnloadReview ResourceType = "provider_first_unload_review"
)

type Status​

type Status string
const (
StatusProcessing Status = "processing"
StatusSucceeded Status = "succeeded"
StatusFailed Status = "failed"
StatusUnknown Status = "unknown"
)

Generated by gomarkdoc