Documentation
¶
Index ¶
- Constants
- Variables
- func AliasHash(alias string) int64
- func AliasHashEncoded(alias string) string
- func AliasHashEncodedf(format string, args ...interface{}) string
- func AliasHashf(format string, args ...interface{}) int64
- func Camel(s string) string
- func Cased(s string, fn ...CasedFn) string
- func Clamp[T Float](v T, minimum T, maximum T) T
- func Clamp01[T Float](v T) T
- func ClampFit[T Float](x T, oldMin T, oldMax T, newMin T, newMax T) T
- func ClampFit01[T Float](x T, newMin T, newMax T) T
- func CtxSlog(ctx context.Context) (logger *slog.Logger, ok bool)
- func CtxWithSlog(ctx context.Context, slog *slog.Logger) context.Context
- func DurationToMilliseconds(d time.Duration) int64
- func Fit[T Float](x T, oldMin T, oldMax T, newMin T, newMax T) T
- func Fit01[T Float](x T, newMin T, newMax T) T
- func FitMax[T Float](x T, newMax T) T
- func FreePort() (port int, err error)
- func JulianDayToTime(d float64) time.Time
- func JulianDayToTimestamp(f float64) *timestamppb.Timestamp
- func JulianNow() float64
- func Kebab(s string) string
- func Lower(s string) string
- func MigrationsFromFS(migrationsFS embed.FS, migrationsDir string) ([]string, error)
- func MillisecondsToDuration(ms int64) time.Duration
- func MustProtoJSONMarshal(msg proto.Message) []byte
- func MustProtoJSONUnmarshal(b []byte, msg proto.Message)
- func MustProtoMarshal(msg proto.Message) []byte
- func MustProtoUnmarshal(b []byte, msg proto.Message)
- func NextEncodedID() string
- func NextID() int64
- func Pascal(s string) string
- func RandIntRange[T Integer](r *rand.Rand, min, max T) T
- func RandNegOneToOneClamped[T Float](r *rand.Rand) T
- func RandSliceItem[T any](r *rand.Rand, slice []T) T
- func RoundFit01[T Float](x T, newMin T, newMax T) T
- func ScreamingSnake(s string) string
- func Snake(s string) string
- func StmtBytes(stmt *sqlite.Stmt, colName string) []byte
- func StmtBytesByCol(stmt *sqlite.Stmt, col int) []byte
- func StmtJulianToTime(stmt *sqlite.Stmt, colName string) time.Time
- func StmtJulianToTimestamp(stmt *sqlite.Stmt, colName string) *timestamppb.Timestamp
- func TimeToJulianDay(t time.Time) float64
- func TimestampJulian(ts *timestamppb.Timestamp) float64
- func Upper(s string) string
- type CasedFn
- type CasedString
- type CtxErrFunc
- type CtxKey
- type Database
- func (db *Database) Close() error
- func (db *Database) ReadTX(ctx context.Context, fn TxFn) (err error)
- func (db *Database) Reset(ctx context.Context, shouldClear bool) (err error)
- func (db *Database) WriteTX(ctx context.Context, fn TxFn) (err error)
- func (db *Database) WriteWithoutTx(ctx context.Context, fn TxFn) error
- type ErrGroupSeparateCtx
- type ErrGroupSharedCtx
- type EventBus
- type EventBusAsync
- type EventBusSync
- type Float
- type Integer
- type MustProtobufHandler
- type Pool
- type Subscriber
- type TxFn
Constants ¶
View Source
const (
UnixEpochJulianDay = 2440587.5
)
Variables ¶
View Source
var (
JulianZeroTime = JulianDayToTime(0)
)
Functions ¶
func AliasHashEncoded ¶
func AliasHashEncodedf ¶
func AliasHashf ¶
func ClampFit01 ¶
func ClampFit01[T Float](x T, newMin T, newMax T) T
func CtxWithSlog ¶ added in v0.0.3
func DurationToMilliseconds ¶ added in v0.2.2
func JulianDayToTime ¶
JulianDayToTime converts a Julian day into a time.Time.
func JulianDayToTimestamp ¶
func JulianDayToTimestamp(f float64) *timestamppb.Timestamp
func MigrationsFromFS ¶ added in v0.3.13
func MillisecondsToDuration ¶ added in v0.2.2
func MustProtoJSONMarshal ¶ added in v0.1.1
func MustProtoJSONUnmarshal ¶ added in v0.1.1
func MustProtoMarshal ¶ added in v0.1.1
func MustProtoUnmarshal ¶ added in v0.1.1
func NextEncodedID ¶
func NextEncodedID() string
func RandIntRange ¶
func RandNegOneToOneClamped ¶
func RandSliceItem ¶ added in v0.3.1
func RoundFit01 ¶
func RoundFit01[T Float](x T, newMin T, newMax T) T
func ScreamingSnake ¶ added in v0.3.8
func StmtJulianToTime ¶ added in v0.2.0
func StmtJulianToTimestamp ¶ added in v0.2.0
func StmtJulianToTimestamp(stmt *sqlite.Stmt, colName string) *timestamppb.Timestamp
func TimeToJulianDay ¶
TimeToJulianDay converts a time.Time into a Julian day.
func TimestampJulian ¶
func TimestampJulian(ts *timestamppb.Timestamp) float64
Types ¶
type CasedString ¶
type CasedString struct { Original string Pascal string Camel string Snake string ScreamingSnake string Kebab string Upper string Lower string }
func ToCasedString ¶ added in v0.0.26
func ToCasedString(s string) CasedString
type CtxErrFunc ¶
func CallNTimesWithDelay ¶ added in v0.3.14
func CallNTimesWithDelay(d time.Duration, n int, fn CtxErrFunc) CtxErrFunc
func Debounce ¶ added in v0.3.14
func Debounce(d time.Duration, fn CtxErrFunc) CtxErrFunc
Debounce will only call the function after d duration has passed since the last call.
func Throttle ¶ added in v0.3.14
func Throttle(d time.Duration, fn CtxErrFunc) CtxErrFunc
Throttle will only allow the function to be called once every d duration.
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func NewDatabase ¶
type ErrGroupSeparateCtx ¶
type ErrGroupSeparateCtx struct {
// contains filtered or unexported fields
}
func NewErrGroupSeparateCtx ¶
func NewErrGroupSeparateCtx() *ErrGroupSeparateCtx
func (*ErrGroupSeparateCtx) Go ¶
func (egc *ErrGroupSeparateCtx) Go(ctx context.Context, funcs ...CtxErrFunc)
func (*ErrGroupSeparateCtx) Wait ¶
func (egc *ErrGroupSeparateCtx) Wait() error
type ErrGroupSharedCtx ¶
type ErrGroupSharedCtx struct {
// contains filtered or unexported fields
}
func NewErrGroupSharedCtx ¶
func NewErrGroupSharedCtx(ctx context.Context, funcs ...CtxErrFunc) *ErrGroupSharedCtx
func (*ErrGroupSharedCtx) Go ¶
func (egc *ErrGroupSharedCtx) Go(funcs ...CtxErrFunc)
func (*ErrGroupSharedCtx) Wait ¶
func (egc *ErrGroupSharedCtx) Wait() error
type EventBus ¶ added in v0.4.4
type EventBus[T any] interface { Subscribe(ctx context.Context, fn Subscriber[T]) context.CancelFunc Emit(ctx context.Context, msg T) error Count() int }
type EventBusAsync ¶ added in v0.4.4
type EventBusAsync[T any] struct { // contains filtered or unexported fields }
func NewEventBusAsync ¶ added in v0.4.4
func NewEventBusAsync[T any]() *EventBusAsync[T]
func (*EventBusAsync[T]) Emit ¶ added in v0.4.4
func (b *EventBusAsync[T]) Emit(ctx context.Context, msg T) error
func (EventBusAsync) Subscribe ¶ added in v0.4.4
func (b EventBusAsync) Subscribe(ctx context.Context, fn Subscriber[T]) context.CancelFunc
type EventBusSync ¶ added in v0.4.4
type EventBusSync[T any] struct { // contains filtered or unexported fields }
func NewEventBusSync ¶ added in v0.4.4
func NewEventBusSync[T any]() *EventBusSync[T]
func (*EventBusSync[T]) Emit ¶ added in v0.4.4
func (b *EventBusSync[T]) Emit(ctx context.Context, msg T) error
func (EventBusSync) Subscribe ¶ added in v0.4.4
func (b EventBusSync) Subscribe(ctx context.Context, fn Subscriber[T]) context.CancelFunc
type MustProtobufHandler ¶ added in v0.2.0
type MustProtobufHandler struct {
// contains filtered or unexported fields
}
func NewProtobufHandler ¶ added in v0.2.0
func NewProtobufHandler(isJSON bool) *MustProtobufHandler
type Pool ¶ added in v0.2.1
type Pool[T any] struct { // contains filtered or unexported fields }
A Pool is a generic wrapper around a sync.Pool.
func New ¶ added in v0.2.1
New creates a new Pool with the provided new function.
The equivalent sync.Pool construct is "sync.Pool{New: fn}"
type Subscriber ¶ added in v0.4.4
Source Files
¶
Click to show internal directories.
Click to hide internal directories.