services

package
v0.0.0-...-20466bc Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCacheMiss = errors.New("cache miss")

ErrCacheMiss indicates that the requested key does not exist in the cache

Functions

This section is empty.

Types

type AuthService

type AuthService struct {
	// contains filtered or unexported fields
}

func NewAuthService

func NewAuthService(config *config.Config) *AuthService

func (*AuthService) CheckPassword

func (s *AuthService) CheckPassword(password, hash string) error

CheckPassword check if a given password matches a given hash

func (*AuthService) GenToken

func (s *AuthService) GenToken(userId string) (string, error)

GenToken generates a token for a user id using JWT which is set to expire based on the duration stored in configuration

func (*AuthService) HashPassword

func (s *AuthService) HashPassword(password string) (string, error)

HashPassword returns a hash of a given password

func (*AuthService) ParseToken

func (s *AuthService) ParseToken(tokenString string) (*types.MyCustomClaims, error)

type CacheClient

type CacheClient struct {
	// contains filtered or unexported fields
}

CacheClient is the client that allows you to interact with the cache

func NewCacheClient

func NewCacheClient(store CacheStore) *CacheClient

NewCacheClient creates a new cache client

func (*CacheClient) Close

func (c *CacheClient) Close()

Close closes the connection to the cache

func (*CacheClient) Flush

func (c *CacheClient) Flush() *CacheFlushOp

Flush creates a cache flush operation

func (*CacheClient) Get

func (c *CacheClient) Get() *CacheGetOp

Get creates a cache get operation

func (*CacheClient) Set

func (c *CacheClient) Set() *CacheSetOp

Set creates a cache set operation

type CacheFlushOp

type CacheFlushOp struct {
	// contains filtered or unexported fields
}

CacheFlushOp handles chaining a flush operation

func (*CacheFlushOp) Execute

func (c *CacheFlushOp) Execute(ctx context.Context) error

Execute flushes the data from the cache

func (*CacheFlushOp) Group

func (c *CacheFlushOp) Group(group string) *CacheFlushOp

Group sets the cache group

func (*CacheFlushOp) Key

func (c *CacheFlushOp) Key(key string) *CacheFlushOp

Key sets the cache key

func (*CacheFlushOp) Tags

func (c *CacheFlushOp) Tags(tags ...string) *CacheFlushOp

Tags sets the cache tags

type CacheGetOp

type CacheGetOp struct {
	// contains filtered or unexported fields
}

CacheGetOp handles chaining a get operation

func (*CacheGetOp) Fetch

func (c *CacheGetOp) Fetch(ctx context.Context) (any, error)

Fetch fetches the data from the cache

func (*CacheGetOp) Group

func (c *CacheGetOp) Group(group string) *CacheGetOp

Group sets the cache group

func (*CacheGetOp) Key

func (c *CacheGetOp) Key(key string) *CacheGetOp

Key sets the cache key

type CacheSetOp

type CacheSetOp struct {
	// contains filtered or unexported fields
}

CacheSetOp handles chaining a set operation

func (*CacheSetOp) Data

func (c *CacheSetOp) Data(data any) *CacheSetOp

Data sets the data to cache

func (*CacheSetOp) Expiration

func (c *CacheSetOp) Expiration(expiration time.Duration) *CacheSetOp

Expiration sets the expiration duration of the cached data

func (*CacheSetOp) Group

func (c *CacheSetOp) Group(group string) *CacheSetOp

Group sets the cache group

func (*CacheSetOp) Key

func (c *CacheSetOp) Key(key string) *CacheSetOp

Key sets the cache key

func (*CacheSetOp) Save

func (c *CacheSetOp) Save(ctx context.Context) error

Save saves the data in the cache

func (*CacheSetOp) Tags

func (c *CacheSetOp) Tags(tags ...string) *CacheSetOp

Tags sets the cache tags

type CacheStore

type CacheStore interface {
	// contains filtered or unexported methods
}

CacheStore provides an interface for cache storage

type Container

type Container struct {
	Web      *echo.Echo
	Config   *config.Config
	Cache    *CacheClient
	Database *sql.DB
	ORM      *ent.Client

	Auth *AuthService
	User *UserService
	Org  *OrgService
}

Container contains all services used by the application and provides an easy way to handle dependency injection including within tests

func NewContainer

func NewContainer() *Container

NewContainer creates and initializes a new Container

func (*Container) Shutdown

func (c *Container) Shutdown() error

Shutdown shuts the Container down and disconnects all connections. If the task runner was started, cancel the context to shut it down prior to calling this.

type InvalidPasswordTokenError

type InvalidPasswordTokenError struct{}

InvalidPasswordTokenError is an error returned when an invalid token is provided

func (InvalidPasswordTokenError) Error

Error implements the error interface.

type NotAuthenticatedError

type NotAuthenticatedError struct{}

NotAuthenticatedError is an error returned when a user is not authenticated

func (NotAuthenticatedError) Error

func (e NotAuthenticatedError) Error() string

Error implements the error interface.

type OrgService

type OrgService struct {
	// contains filtered or unexported fields
}

func NewOrgService

func NewOrgService(orm *ent.Client) *OrgService

func (*OrgService) Create

func (s *OrgService) Create(ctx context.Context, input *types.OrgCreateInput) (*ent.Org, error)

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

func NewUserService

func NewUserService(orm *ent.Client) *UserService

func (*UserService) Create

func (s *UserService) Create(ctx context.Context, email, password string) (*ent.User, error)

func (*UserService) FindByEmail

func (s *UserService) FindByEmail(ctx context.Context, email string) (*ent.User, error)

func (*UserService) FindById

func (s *UserService) FindById(ctx context.Context, id string) (*ent.User, error)

func (*UserService) UpdatePassword

func (s *UserService) UpdatePassword(ctx context.Context, id string, encryptPassword string) (*ent.User, error)

Jump to

Keyboard shortcuts

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