adapters

package
v0.0.0-...-de18be0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FiberMetadata = newFiberMetadataKey()
View Source
var FiberO11YMetric = wfiber.NewO11YMetric(pkg.Version().ServiceName)

Functions

func ConvertErrorFromHttpClient

func ConvertErrorFromHttpClient(err error) error

ConvertErrorFromHttpClient 還不知道會有怎樣的 http error, 所以只先定義預設錯誤

func ConvertErrorFromRedis

func ConvertErrorFromRedis(err error) error

func GetHttpJsonBodyByType

func GetHttpJsonBodyByType[T any](

	client *http.Client,
	logger *slog.Logger,

	ctx context.Context,
	endpoint string,
) (view T, Err error)

func GetLocalCacheByType

func GetLocalCacheByType[T any](store *bigcache.BigCache, key string) (val T, Err error)

func GetRedisStringByType

func GetRedisStringByType[T any](

	client *redis.Client,
	unmarshal utility.Unmarshal,
	logger *slog.Logger,

	ctx context.Context,
	key string,
) (resp T, Err error)

func HandleErrorByFiber

func HandleErrorByFiber(c *fiber.Ctx, err error) error

func NewHttpClient

func NewHttpClient() *http.Client

func NewLocalCache

func NewLocalCache() (*bigcache.BigCache, error)

func NewMessageConsumer

func NewMessageConsumer()

func NewMessageProducer

func NewMessageProducer()

func NewMySqlGorm

func NewMySqlGorm(conf *pkg.MySql) (*gorm.DB, error)

func NewRedis

func NewRedis(conf *pkg.Redis) (*redis.Client, error)

func ParseDataflowByFiber

func ParseDataflowByFiber(ingress *dataflow.Message, req any, logger *slog.Logger) (bool, error)

func ParseQueryByFiber

func ParseQueryByFiber(c *fiber.Ctx, req any, logger *slog.Logger) (bool, error)

func SetLocalCacheByType

func SetLocalCacheByType[T any](store *bigcache.BigCache, key string, val *T) (Err error)

Types

type ErrorResponse

type ErrorResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func NewErrorResponse

func NewErrorResponse(code int, message string) *ErrorResponse

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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