foundations

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func EnableErrorWithEmptyList added in v0.1.7

func EnableErrorWithEmptyList(v bool)

EnableErrorWithEmptyList Make the list return an error if it is empty.

func Get

func Get(ctx context.Context, cli GetClient, getKeys GetKeyFunc, fetch FetchItemFunc, opt ...options.Option) (*dynamodb.GetItemOutput, error)

func IsNil

func IsNil(record interface{}) bool

func IsNotFound

func IsNotFound(err error) bool

func NotFound added in v0.1.4

func NotFound(tableName string) *types.ResourceNotFoundException

func Put

func Query added in v0.0.2

func Scan added in v0.0.6

func Scan(ctx context.Context, cli ScanClient, condition ScanFilterFunc, fetch FetchItemsFunc, opt ...options.Option) (*dynamodb.ScanOutput, error)

func ScanAll added in v0.1.16

func ScanAll(ctx context.Context, cli ScanClient, condition ScanFilterFunc, fetch FetchItemsFunc, opt ...options.Option) (out *dynamodb.ScanOutput, err error)

func Setup added in v0.1.11

func Setup(ctx context.Context, option ...ConfigOption) (cli *dynamodb.Client, err error)

func UpdateBuilder added in v0.1.3

func UpdateBuilder(ctx context.Context, fields ...UpdateField) expression.UpdateBuilder

func Values added in v0.1.13

func Values[T any](values ...T) (right expression.OperandBuilder, other []expression.OperandBuilder)

Types

type Client added in v0.1.3

type Client interface {
	GetClient
	ScanClient
	QueryClient
	WriteClient
}

type Config added in v0.1.11

type Config struct {
	Local          bool
	Region         string
	Endpoint       string
	Profile        string
	Debug          bool
	EnabledTracing bool
	Cfg            *aws.Config
}

type ConfigBuilder added in v0.1.11

type ConfigBuilder interface {
	Build(ctx context.Context) []ConfigOption
}

type ConfigOption added in v0.1.17

type ConfigOption func(*Config)

func AwsConfig added in v0.1.17

func AwsConfig(cfg *aws.Config) ConfigOption

func Debug added in v0.1.17

func Debug() ConfigOption

func EnabledTracing added in v0.1.17

func EnabledTracing() ConfigOption

func Endpoint added in v0.1.17

func Endpoint(endpoint string) ConfigOption

func Local added in v0.1.17

func Local() ConfigOption

func Profile added in v0.1.17

func Profile(profile string) ConfigOption

func Region added in v0.1.17

func Region(region string) ConfigOption

type EnvBuilder added in v0.1.11

type EnvBuilder struct{}

func (*EnvBuilder) Build added in v0.1.11

func (b *EnvBuilder) Build(ctx context.Context) (options []ConfigOption)

type EvaluatedKey added in v0.1.9

type EvaluatedKey map[string]types.AttributeValue

func EvaluatedKeyOf added in v0.1.9

func EvaluatedKeyOf(key string) (EvaluatedKey, error)

func (EvaluatedKey) String added in v0.1.9

func (ek EvaluatedKey) String() (string, error)

type EvaluatedValue added in v0.1.9

type EvaluatedValue struct {
	Type  string `json:"t"`
	Value string `json:"v"`
}

type ExpressionFunc added in v0.1.6

type ExpressionFunc func() (expr expression.Expression, err error)

type FetchItemFunc

type FetchItemFunc func(tableName string, value Record) error

func FetchItem added in v0.1.3

func FetchItem[T any](ctx context.Context, rec *T) FetchItemFunc

type FetchItemPostprocessor added in v0.1.11

type FetchItemPostprocessor interface {
	AfterFetchItem(ctx context.Context) error
}

type FetchItemsFunc added in v0.0.2

type FetchItemsFunc func(tableName string, value Records) error

func FetchAll added in v0.1.16

func FetchAll[T any](ctx context.Context, list []T) FetchItemsFunc

func FetchItems added in v0.1.3

func FetchItems[T any](ctx context.Context, rec *T) FetchItemsFunc

type FetchItemsPostprocessor added in v0.1.11

type FetchItemsPostprocessor interface {
	AfterFetchItems(ctx context.Context) error
}

type GetClient

type GetClient interface {
	GetItem(ctx context.Context, params *dynamodb.GetItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.GetItemOutput, error)
}

type GetItemFunc added in v0.0.9

type GetItemFunc WriteItemFunc

type GetKeyFunc

type GetKeyFunc func() (table string, keys map[string]types.AttributeValue, attrs []string, err error)

type OptionBuilder added in v0.1.12

type OptionBuilder struct {
	Local          bool
	Region         string
	Endpoint       string
	Profile        string
	Debug          bool
	EnabledTracing bool
	Cfg            *aws.Config
}

func (*OptionBuilder) Build added in v0.1.12

func (b *OptionBuilder) Build(ctx context.Context) (options []ConfigOption)

type PutItemPreprocessor added in v0.1.3

type PutItemPreprocessor interface {
	BeforePutItem(ctx context.Context) (any, error)
}

type QueryClient added in v0.0.2

type QueryClient interface {
	Query(ctx context.Context, params *dynamodb.QueryInput, optFns ...func(*dynamodb.Options)) (*dynamodb.QueryOutput, error)
}

type QueryConditionFunc added in v0.0.2

type QueryConditionFunc func() (table, index string, expr expression.Expression, err error)

type Record added in v0.1.9

type Record map[string]types.AttributeValue

func (Record) Unmarshal added in v0.1.9

func (r Record) Unmarshal(ctx context.Context, v any) error

type Records added in v0.1.9

type Records []map[string]types.AttributeValue

func (Records) Unmarshal added in v0.1.9

func (r Records) Unmarshal(ctx context.Context, v any) error

type ScanClient added in v0.0.6

type ScanClient interface {
	Scan(ctx context.Context, params *dynamodb.ScanInput, optFns ...func(*dynamodb.Options)) (*dynamodb.ScanOutput, error)
}

type ScanFilterFunc added in v0.1.3

type ScanFilterFunc func() (table string, expr expression.Expression, err error)

type UpdateField

type UpdateField func(ctx context.Context, builder *expression.UpdateBuilder) expression.UpdateBuilder

func AddValue added in v0.1.17

func AddValue(name string, value any) UpdateField

func DeleteValue added in v0.1.17

func DeleteValue(name string, value any) UpdateField

func RemoveValue added in v0.1.17

func RemoveValue(name string) UpdateField

func SetValue added in v0.1.17

func SetValue(name string, value any) UpdateField

func UpdateValue added in v0.1.3

func UpdateValue(name string, value any) UpdateField

type WriteClient

type WriteClient interface {
	PutItem(ctx context.Context, params *dynamodb.PutItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.PutItemOutput, error)
	UpdateItem(ctx context.Context, params *dynamodb.UpdateItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.UpdateItemOutput, error)
	DeleteItem(ctx context.Context, params *dynamodb.DeleteItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.DeleteItemOutput, error)
}

type WriteItemFunc

type WriteItemFunc func() (table string, item map[string]types.AttributeValue, expr expression.Expression, err error)

func ConsistentUpdateItem added in v0.1.3

func ConsistentUpdateItem(ctx context.Context, keyFunc GetKeyFunc, fieldName string, count int, fields ...UpdateField) WriteItemFunc

func DeleteItem added in v0.1.3

func DeleteItem(keyFunc GetKeyFunc) WriteItemFunc

func PutItem added in v0.1.3

func PutItem(ctx context.Context, tableName string, rec any, f ...ExpressionFunc) WriteItemFunc

func UpdateItem added in v0.1.3

func UpdateItem(ctx context.Context, keyFunc GetKeyFunc, fields ...UpdateField) WriteItemFunc

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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