Documentation
¶
Index ¶
- type DepositRequest
- type GatewayClient
- func (c *GatewayClient) CreateDeposit(ctx context.Context, token, walletID string, amountPaise int64, ...) error
- func (c *GatewayClient) CreateTransfer(ctx context.Context, token, sourceWalletID, destWalletID string, ...) error
- func (c *GatewayClient) CreateWithdrawal(ctx context.Context, token, walletID string, amountPaise int64, ...) error
- func (c *GatewayClient) GetUserWallet(ctx context.Context, token, userID string) (*WalletResponse, error)
- func (c *GatewayClient) Login(ctx context.Context, identifier, password string) (*LoginResponse, error)
- func (c *GatewayClient) Logout(ctx context.Context, token string) error
- func (c *GatewayClient) RegisterUser(ctx context.Context, email, phone, fullName, password string) (*RegisterResponse, error)
- func (c *GatewayClient) SubmitKYC(ctx context.Context, token string, kycReq KYCSubmitRequest) error
- func (c *GatewayClient) VerifyKYC(ctx context.Context, userID string) error
- type KYCAddressRequest
- type KYCSubmitRequest
- type LoginRequest
- type LoginResponse
- type RegisterRequest
- type RegisterResponse
- type SimulatedUser
- type SimulationEngine
- type TransferRequest
- type UserLifecycleManager
- func (m *UserLifecycleManager) GenerateNewUser() *SimulatedUser
- func (m *UserLifecycleManager) GetActiveUsers() []*SimulatedUser
- func (m *UserLifecycleManager) GetUsers() []*SimulatedUser
- func (m *UserLifecycleManager) LoginUser(ctx context.Context, user *SimulatedUser) error
- func (m *UserLifecycleManager) LogoutUser(ctx context.Context, user *SimulatedUser) error
- func (m *UserLifecycleManager) RegisterUser(ctx context.Context, user *SimulatedUser) error
- func (m *UserLifecycleManager) SubmitKYC(ctx context.Context, user *SimulatedUser) error
- func (m *UserLifecycleManager) VerifyKYC(ctx context.Context, user *SimulatedUser) error
- type UserStage
- type UserWallet
- type WalletResponse
- type WithdrawalRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DepositRequest ¶
type DepositRequest struct {
WalletID string `json:"wallet_id"`
Amount int64 `json:"amount"` // Amount in smallest unit (paise)
Currency string `json:"currency"`
Description string `json:"description"`
}
DepositRequest represents a deposit transaction request
type GatewayClient ¶
type GatewayClient struct {
*clients.BaseClient
}
GatewayClient makes API calls to the Nivo Gateway
func NewGatewayClient ¶
func NewGatewayClient(baseURL, authToken string) *GatewayClient
NewGatewayClient creates a new gateway client with admin auth token
func (*GatewayClient) CreateDeposit ¶
func (c *GatewayClient) CreateDeposit(ctx context.Context, token, walletID string, amountPaise int64, description string) error
CreateDeposit creates a deposit transaction. If token is provided, it's used for auth. Otherwise, falls back to client's default auth headers.
func (*GatewayClient) CreateTransfer ¶
func (c *GatewayClient) CreateTransfer(ctx context.Context, token, sourceWalletID, destWalletID string, amountPaise int64, description string) error
CreateTransfer creates a transfer transaction. If token is provided, it's used for auth. Otherwise, falls back to client's default auth headers.
func (*GatewayClient) CreateWithdrawal ¶
func (c *GatewayClient) CreateWithdrawal(ctx context.Context, token, walletID string, amountPaise int64, description string) error
CreateWithdrawal creates a withdrawal transaction. If token is provided, it's used for auth. Otherwise, falls back to client's default auth headers.
func (*GatewayClient) GetUserWallet ¶
func (c *GatewayClient) GetUserWallet(ctx context.Context, token, userID string) (*WalletResponse, error)
GetUserWallet fetches the wallet for a given user
func (*GatewayClient) Login ¶
func (c *GatewayClient) Login(ctx context.Context, identifier, password string) (*LoginResponse, error)
Login authenticates a user and returns a session token
func (*GatewayClient) Logout ¶
func (c *GatewayClient) Logout(ctx context.Context, token string) error
Logout terminates a user session
func (*GatewayClient) RegisterUser ¶
func (c *GatewayClient) RegisterUser(ctx context.Context, email, phone, fullName, password string) (*RegisterResponse, error)
RegisterUser creates a new user account
func (*GatewayClient) SubmitKYC ¶
func (c *GatewayClient) SubmitKYC(ctx context.Context, token string, kycReq KYCSubmitRequest) error
SubmitKYC submits KYC information for a user
type KYCAddressRequest ¶
type KYCAddressRequest struct {
Street string `json:"street"`
City string `json:"city"`
State string `json:"state"`
PIN string `json:"pin"`
Country string `json:"country"`
}
KYCAddressRequest represents address in KYC request
type KYCSubmitRequest ¶
type KYCSubmitRequest struct {
PAN string `json:"pan"`
Aadhaar string `json:"aadhaar"`
DateOfBirth string `json:"date_of_birth"`
Address KYCAddressRequest `json:"address"`
}
KYCSubmitRequest represents a KYC submission request Matches identity service's UpdateKYCRequest format
type LoginRequest ¶
type LoginRequest struct {
Identifier string `json:"identifier"`
Password string `json:"password"`
}
LoginRequest represents a login request
type LoginResponse ¶
type LoginResponse struct {
Token string `json:"token"`
User struct {
ID string `json:"id"`
Email string `json:"email"`
FullName string `json:"full_name"`
} `json:"user"`
}
LoginResponse represents the response from login
type RegisterRequest ¶
type RegisterRequest struct {
Email string `json:"email"`
Phone string `json:"phone"`
FullName string `json:"full_name"`
Password string `json:"password"`
}
RegisterRequest represents a user registration request
type RegisterResponse ¶
type RegisterResponse struct {
ID string `json:"id"`
Email string `json:"email"`
Phone string `json:"phone"`
FullName string `json:"full_name"`
Status string `json:"status"`
}
RegisterResponse represents the response from user registration
type SimulatedUser ¶
type SimulatedUser struct {
// Identity
Email string
Password string
FullName string
PhoneNumber string
// State
UserID string // Set after registration
WalletID string // Set after wallet creation
SessionToken string // Set after login
Persona personas.PersonaType
// Lifecycle tracking
Stage UserStage
Balance int64
CreatedAt time.Time
LastActive time.Time
LastLogin time.Time
}
SimulatedUser represents a user created and managed by the simulation engine
type SimulationEngine ¶
type SimulationEngine struct {
// contains filtered or unexported fields
}
SimulationEngine generates synthetic transactions
func NewSimulationEngine ¶
func NewSimulationEngine( db *sql.DB, gatewayClient *GatewayClient, cfg *config.SimulationConfig, met *metrics.SimulationMetrics, ) *SimulationEngine
NewSimulationEngine creates a new simulation engine
func (*SimulationEngine) IsRunning ¶
func (s *SimulationEngine) IsRunning() bool
IsRunning returns whether the simulation is running (thread-safe).
func (*SimulationEngine) LoadUsers ¶
func (s *SimulationEngine) LoadUsers(ctx context.Context) error
LoadUsers loads users and wallets from the database
func (*SimulationEngine) Start ¶
func (s *SimulationEngine) Start(ctx context.Context)
Start starts the simulation engine
type TransferRequest ¶
type TransferRequest struct {
SourceWalletID string `json:"source_wallet_id"`
DestinationWalletID string `json:"destination_wallet_id"`
Amount int64 `json:"amount"` // Amount in smallest unit (paise)
Currency string `json:"currency"`
Description string `json:"description"`
}
TransferRequest represents a transfer transaction request
type UserLifecycleManager ¶
type UserLifecycleManager struct {
// contains filtered or unexported fields
}
UserLifecycleManager manages the lifecycle of simulated users
func NewUserLifecycleManager ¶
func NewUserLifecycleManager(gatewayClient *GatewayClient, db *sql.DB) *UserLifecycleManager
NewUserLifecycleManager creates a new user lifecycle manager
func (*UserLifecycleManager) GenerateNewUser ¶
func (m *UserLifecycleManager) GenerateNewUser() *SimulatedUser
GenerateNewUser creates a new simulated user with random persona
func (*UserLifecycleManager) GetActiveUsers ¶
func (m *UserLifecycleManager) GetActiveUsers() []*SimulatedUser
GetActiveUsers returns users who are KYC verified or active
func (*UserLifecycleManager) GetUsers ¶
func (m *UserLifecycleManager) GetUsers() []*SimulatedUser
GetUsers returns all simulated users
func (*UserLifecycleManager) LoginUser ¶
func (m *UserLifecycleManager) LoginUser(ctx context.Context, user *SimulatedUser) error
LoginUser logs in a user and obtains a session token
func (*UserLifecycleManager) LogoutUser ¶
func (m *UserLifecycleManager) LogoutUser(ctx context.Context, user *SimulatedUser) error
LogoutUser logs out a user
func (*UserLifecycleManager) RegisterUser ¶
func (m *UserLifecycleManager) RegisterUser(ctx context.Context, user *SimulatedUser) error
RegisterUser registers a new user in the system
func (*UserLifecycleManager) SubmitKYC ¶
func (m *UserLifecycleManager) SubmitKYC(ctx context.Context, user *SimulatedUser) error
SubmitKYC submits KYC information for a user with retry on failure
func (*UserLifecycleManager) VerifyKYC ¶
func (m *UserLifecycleManager) VerifyKYC(ctx context.Context, user *SimulatedUser) error
VerifyKYC uses local database bypass to verify a user's KYC (simulated users only)
type UserStage ¶
type UserStage string
UserStage represents the lifecycle stage of a simulated user
const ( StageNew UserStage = "NEW" // Ready to register StageRegistered UserStage = "REGISTERED" // Registered, needs KYC StageKYCSubmitted UserStage = "KYC_SUBMITTED" // KYC submitted, awaiting verification StageKYCVerified UserStage = "KYC_VERIFIED" // KYC verified, can transact StageActive UserStage = "ACTIVE" // Fully active user )
type UserWallet ¶
type UserWallet struct {
UserID string
WalletID string
Email string
Persona personas.PersonaType
Balance int64 // Current balance in paise
}
UserWallet represents a user with their wallet