Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hook ¶
type Hook struct {
ID string `json:"id"` // Unique identifier for the hook
Name string `json:"name"` // Friendly name for the hook
URL string `json:"url"` // Webhook endpoint URL
Type HookType `json:"type"` // Type of hook (pre or post transaction)
Active bool `json:"active"` // Whether the hook is currently active
Timeout int `json:"timeout"` // Timeout in seconds for the webhook call
RetryCount int `json:"retry_count"` // Number of retries on failure
CreatedAt time.Time `json:"created_at"` // Creation timestamp
LastRun time.Time `json:"last_run"` // Last execution timestamp
LastSuccess bool `json:"last_success"` // Status of last execution
}
Hook represents a webhook configuration.
type HookManager ¶
type HookManager interface {
RegisterHook(ctx context.Context, hook *Hook) error
UpdateHook(ctx context.Context, hookID string, hook *Hook) error
DeleteHook(ctx context.Context, hookID string) error
GetHook(ctx context.Context, hookID string) (*Hook, error)
ListHooks(ctx context.Context, hookType HookType) ([]*Hook, error)
ExecutePreHooks(ctx context.Context, transactionID string, data interface{}) error
ExecutePostHooks(ctx context.Context, transactionID string, data interface{}) error
ProcessHookTask(ctx context.Context, task *asynq.Task) error
}
HookManager defines the interface for managing hooks.
func NewHookManager ¶
func NewHookManager(redisClient redis.UniversalClient, queue *asynq.Client) HookManager
NewHookManager creates a new Redis-based hook manager. It initializes the hook manager with the provided Redis client and Asynq client.
Parameters: - redisClient: The Redis client for storing hook configurations. - queue: The Asynq client for queuing hook execution tasks.
Returns: - HookManager: A new instance of the hook manager.
type HookPayload ¶
type HookPayload struct {
TransactionID string `json:"transaction_id"`
HookType HookType `json:"hook_type"`
Timestamp time.Time `json:"timestamp"`
Data json.RawMessage `json:"data,omitempty"` // Changed to omitempty to handle nil data
}
HookPayload represents the data sent to webhook endpoints.
type HookResponse ¶
type HookResponse struct {
Success bool `json:"success"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
HookResponse represents the expected response from webhook endpoints.
type HookTaskPayload ¶ added in v0.11.5
type HookTaskPayload struct {
Hook *Hook `json:"hook"`
Payload HookPayload `json:"payload"`
TransactionID string `json:"transaction_id"`
Data interface{} `json:"data"`
Transaction *model.Transaction `json:"transaction"`
}
HookTaskPayload represents the payload for a queued hook task.
Click to show internal directories.
Click to hide internal directories.