dovewing

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2024 License: MIT Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetUser

func GetUser(ctx context.Context, id string, platform Platform) (*dovetypes.PlatformUser, error)

Fetches a user based on the platform

func InitPlatform

func InitPlatform(platform Platform) error

Common platform init code

func TableName

func TableName(platform Platform) string

Returns the table name of a platform

Types

type BaseState

type BaseState struct {
	Logger            *zap.Logger
	Context           context.Context
	Pool              *pgxpool.Pool
	PlatformUserCache hotcache.HotCache[dovetypes.PlatformUser]
	Middlewares       []func(p Platform, u *dovetypes.PlatformUser) (*dovetypes.PlatformUser, error)
	UserExpiryTime    time.Duration
}

type ClearFrom

type ClearFrom string
const (
	ClearFromInternalUserCache ClearFrom = "iuc"
	ClearFromRedis             ClearFrom = "redis"
)

type ClearUserInfo

type ClearUserInfo struct {
	// The user that was cleared
	ClearedFrom []ClearFrom

	// Whether the user was a bot or not
	IsBot bool
}

ClearUserInfo contains information on a clear operation

func ClearUser

func ClearUser(ctx context.Context, id string, platform Platform, req ClearUserReq) (*ClearUserInfo, error)

Clears a user of a platform

type ClearUserReq

type ClearUserReq struct {
	// Where to clear from
	//
	// iuc -> internal user cache (postgres)
	//
	// Redis -> redis cache
	//
	//
	// If not specified, will clear from all
	ClearFrom []ClearFrom
}

type Platform

type Platform interface {
	// initializes a platform, most of the time, needs no implementation
	Init() error
	// returns whether or not the platform is initialized, init() must set this to true if called
	Initted() bool
	// Returns the base state
	GetState() *BaseState
	// returns the name of the platform, used for cache table names
	PlatformName() string
	// validate the id, if feasible
	ValidateId(id string) (string, error)
	// try and find the user in the platform's cache, should only hit cache
	//
	// if user not found, return nil, nil (error should be nil and user obj should be nil)
	//
	// note that returning a error here will cause the user to not be fetched from the platform
	PlatformSpecificCache(ctx context.Context, id string) (*dovetypes.PlatformUser, error)
	// fetch a user from the platform, at this point, assume that cache has been checked
	GetUser(ctx context.Context, id string) (*dovetypes.PlatformUser, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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