actions

package
v0.0.0-...-08fea6f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorAction rules.ActionFunc = func(ctx context.Context) (context.Context, error) {
	return ctx, fmt.Errorf("error occurred")
}
View Source
var IdempotencyAction rules.ActionFunc = func(ctx context.Context) (context.Context, error) {
	customerID := ctx.Value("customer_id")
	if customerID == nil {
		return ctx, fmt.Errorf("customer_id not found in context")
	}

	ik := fmt.Sprintf("customer_id:%d", ctx.Value("customer_id").(int))

	log.Println("identifying customer with key:", ik)
	return ctx, nil
}

Functions

func CreateAction

func CreateAction(actionType string, config ActionConfig) rules.ActionFunc

CreateAction creates an ActionFunc based on the action type

Types

type ActionConfig

type ActionConfig struct {
	URL   string `json:"url"`   // Example config for fetching data
	Value string `json:"value"` // Example config for logging
}

ActionConfig defines the structure for action configurations

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL