mw

package
v0.0.0-...-2af345c Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2020 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapCacheRepository

func WrapCacheRepository(c repository.Cache, l *log.Logger) repository.Cache

HoC-like repository wrapping using the chain of responsibility pattern. This wraps required layers to each repository's endpoint such as:

- Observability (Logging, Metrics and Tracing)

- Resiliency strategies (Circuit Breaking and Retry Policy)

func WrapUserRepository

func WrapUserRepository(r repository.User, c repository.Cache, l *log.Logger) repository.User

HoC-like repository wrapping using the chain of responsibility pattern. This wraps required layers to any repository's endpoint such as:

- Observability (Metrics and Tracing)

- Query Caching

- Resiliency strategies (Circuit Breaking and Retry Policy)

Types

type CacheLog

type CacheLog struct {
	Logger *log.Logger
	Next   repository.Cache
}

func (CacheLog) Invalidate

func (c CacheLog) Invalidate(ctx context.Context, table, key string) (err error)

func (CacheLog) Read

func (c CacheLog) Read(ctx context.Context, table, key string) (string, error)

func (CacheLog) Write

func (c CacheLog) Write(ctx context.Context, table, key string, value interface{}, duration time.Duration) (err error)

type CacheMetric

type CacheMetric struct {
	Next repository.Cache
}

func NewCacheMetric

func NewCacheMetric(n repository.Cache, l *log.Logger) CacheMetric

func (CacheMetric) Invalidate

func (c CacheMetric) Invalidate(ctx context.Context, table, key string) (err error)

func (CacheMetric) Read

func (c CacheMetric) Read(ctx context.Context, table, key string) (res string, err error)

func (CacheMetric) Write

func (c CacheMetric) Write(ctx context.Context, table, key string, value interface{}, duration time.Duration) (err error)

type CacheRetryPolicy

type CacheRetryPolicy struct {
	Logger *log.Logger
	Next   repository.Cache
}

func (CacheRetryPolicy) Invalidate

func (c CacheRetryPolicy) Invalidate(ctx context.Context, table, key string) error

func (CacheRetryPolicy) Read

func (c CacheRetryPolicy) Read(ctx context.Context, table, key string) (string, error)

func (CacheRetryPolicy) Write

func (c CacheRetryPolicy) Write(ctx context.Context, table, key string, value interface{}, duration time.Duration) error

type CacheTracing

type CacheTracing struct {
	Next repository.Cache
}

func (CacheTracing) Invalidate

func (c CacheTracing) Invalidate(ctx context.Context, table, key string) (err error)

func (CacheTracing) Read

func (c CacheTracing) Read(ctx context.Context, table, key string) (res string, err error)

func (CacheTracing) Write

func (c CacheTracing) Write(ctx context.Context, table, key string, value interface{}, duration time.Duration) (err error)

type UserRepositoryCache

type UserRepositoryCache struct {
	Cache repository.Cache
	Next  repository.User
}

func (UserRepositoryCache) Fetch

func (u UserRepositoryCache) Fetch(ctx context.Context, criteria domain.Criteria) (users []*aggregate.UserRoot,
	nextToken domain.PaginationToken, err error)

func (UserRepositoryCache) FetchOne

func (u UserRepositoryCache) FetchOne(ctx context.Context, byUsername bool, key string) (user *aggregate.UserRoot, err error)

func (UserRepositoryCache) HardRemove

func (u UserRepositoryCache) HardRemove(ctx context.Context, id string) (err error)

func (UserRepositoryCache) Remove

func (u UserRepositoryCache) Remove(ctx context.Context, id string) (err error)

func (UserRepositoryCache) Restore

func (u UserRepositoryCache) Restore(ctx context.Context, id string) (err error)

type UserRepositoryMetric

type UserRepositoryMetric struct {
	Next repository.User
}

func NewUserRepositoryMetric

func NewUserRepositoryMetric(n repository.User, l *log.Logger) UserRepositoryMetric

func (UserRepositoryMetric) Fetch

func (u UserRepositoryMetric) Fetch(ctx context.Context, criteria domain.Criteria) (users []*aggregate.UserRoot,
	nextToken domain.PaginationToken, err error)

func (UserRepositoryMetric) FetchOne

func (u UserRepositoryMetric) FetchOne(ctx context.Context, byUsername bool, key string) (user *aggregate.UserRoot, err error)

func (UserRepositoryMetric) HardRemove

func (u UserRepositoryMetric) HardRemove(ctx context.Context, id string) (err error)

func (UserRepositoryMetric) Remove

func (u UserRepositoryMetric) Remove(ctx context.Context, id string) (err error)

func (UserRepositoryMetric) Restore

func (u UserRepositoryMetric) Restore(ctx context.Context, id string) (err error)

type UserRepositoryTracing

type UserRepositoryTracing struct {
	Next repository.User
}

func (UserRepositoryTracing) Fetch

func (u UserRepositoryTracing) Fetch(ctx context.Context, criteria domain.Criteria) (users []*aggregate.UserRoot,
	nextToken domain.PaginationToken, err error)

func (UserRepositoryTracing) FetchOne

func (u UserRepositoryTracing) FetchOne(ctx context.Context, byUsername bool, key string) (user *aggregate.UserRoot, err error)

func (UserRepositoryTracing) HardRemove

func (u UserRepositoryTracing) HardRemove(ctx context.Context, id string) (err error)

func (UserRepositoryTracing) Remove

func (u UserRepositoryTracing) Remove(ctx context.Context, id string) (err error)

func (UserRepositoryTracing) Restore

func (u UserRepositoryTracing) Restore(ctx context.Context, id string) (err error)

Jump to

Keyboard shortcuts

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