util

package
v0.0.0-...-bc5b573 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2025 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFromContext

func GetFromContext[T any](ctx context.Context, key any) *T

func ParseUUID

func ParseUUID(ctx context.Context, p ParseUUIDParams) (uuid.UUID, error)

ParseUUID avoids doing the logging and error handling for protobuf every f*cking time a uuid is being passed as a string. - str is the string formatted uuid - subject is what the uuid represents (ex: user_id, task_id, jwt_id) - critical helps define how to handle errors around the token.

  • user can f*ck up -> !critical as the error might not be our fault -> warning
  • DBs shouldn't fuck up -> critical as this implies a greater internal issue -> error

- implications define what an error implies for the user (which protobuf status code response)

Types

type ConfigStore

type ConfigStore struct {
	AllowNewUsers bool
	MaxUsers      int
	MinPasswdLen  int
	MaxPasswdLen  int
	JWTAccessTTL  time.Duration
	JWTRefreshTTL time.Duration
	DBCacheSize   int
	ArgonThreads  uint
}

type ContextKey

type ContextKey uint8
const (
	DBKey ContextKey = iota
	ReqIDKey
	ProtoMethodKey
	ProtoServerKey
	CredsKey       // Generated from Bearer tokens
	CredentialsKey // Generated from Basic tokens
)

type ParseUUIDParams

type ParseUUIDParams struct {
	Str         string
	Subject     string
	Implication codes.Code
	Critical    bool
}

Jump to

Keyboard shortcuts

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