core

package module
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 39 Imported by: 7

Documentation

Index

Constants

View Source
const (
	DateFormat         = "2006-01-02"
	DateTimeFormat     = "2006-01-02 15:04:05"
	DateTimeZoneFormat = "2006-01-02T15:04:05.999Z07:00"
)
View Source
const ErrValidation = "ERR_VALIDATION"

Variables

View Source
var AppName string
View Source
var BuildDate string
View Source
var BuildVersion string
View Source
var HealthHandler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
	w.WriteHeader(http.StatusOK)
	_, _ = w.Write([]byte("OK"))
})

HealthHandler is a simple liveness endpoint that always returns HTTP 200 OK.

View Source
View Source
var Mode = os.Getenv("MODE")
View Source
var Task = &cobra.Command{}
View Source
var TaskConfig any
View Source
var Translator = ut.New(it.New(), it.New())
View Source
var Validator = validator.New()

Functions

func AddEndpointNameMetrics

func AddEndpointNameMetrics(str string, ctx context.Context) context.Context

func ConvertStringToTimeDate

func ConvertStringToTimeDate(input string) (time.Time, error)

func DatePtrToString added in v0.0.3

func DatePtrToString(date *time.Time) string

func DatePtrToStringPtr added in v0.0.3

func DatePtrToStringPtr(date *time.Time) *string

func DateTimeToString

func DateTimeToString(date time.Time) string

func DateToString

func DateToString(date time.Time) string

func DateToStringPtr

func DateToStringPtr(date time.Time) *string

func Decrypt added in v0.0.19

func Decrypt(ciphertextHex string, keyStr string) ([]byte, error)

decrypt decritta un messaggio esadecimale usando l'AppID come chiave. Il nonce è atteso all'inizio del ciphertext decodificato da hex.

func Encrypt added in v0.0.19

func Encrypt(plaintext []byte, keyStr string) ([]byte, error)

func Exec added in v0.0.11

func Exec[T ITaskRunner](runner T, shutdowner fx.Shutdowner)

func Execute added in v0.0.5

func Execute[T ITaskRunner]()

func GenerateHttpClientWithInstrumentation

func GenerateHttpClientWithInstrumentation(serviceName string) *http.Client

func GetHostname

func GetHostname() string

func GetMidnight added in v0.0.3

func GetMidnight(t time.Time) time.Time

func GetTimestamp

func GetTimestamp() string

func Invoke

func Invoke(invoke interface{})

func InvokeIf

func InvokeIf(invoke interface{}, acceptedmodes ...string)

func NowString

func NowString() string

func NowTime

func NowTime() time.Time

func Populate added in v0.0.11

func Populate(top interface{})

func Provides

func Provides(methods ...interface{})

func ProvidesAndSupplyIf

func ProvidesAndSupplyIf(provide interface{}, supply interface{}, acceptedmodes ...string)

func ProvidesIf

func ProvidesIf(provide interface{}, acceptedmodes ...string)

func ReadConfig

func ReadConfig(projectConfigFile, ConfigFileEnvVar string, appconfig any) error

func Run added in v0.0.5

func Run()

func Start

func Start(ctx context.Context) (*fx.App, error)

func StringPtrToString added in v0.0.4

func StringPtrToString(s *string) string

func StringToDatePtr

func StringToDatePtr(date string) *time.Time

func StringToDateTime

func StringToDateTime(date string) time.Time

func StringToDateTimePtr

func StringToDateTimePtr(date string) *time.Time

func Supply

func Supply(ifaces ...interface{})

func SupplyIf

func SupplyIf(iface interface{}, acceptedmodes ...string)

Types

type ApplicationError

type ApplicationError struct {
	StatusCode int    `json:"-" bson:"statusCode"`
	Ambit      string `json:"ambit"`
	Code       string `json:"code"`
	Message    string `json:"message"`
}

func BusinessErrorWithCodeAndMessage

func BusinessErrorWithCodeAndMessage(code, message string) *ApplicationError

func BusinessErrorWithError

func BusinessErrorWithError(err error) *ApplicationError

func NotFoundError

func NotFoundError() *ApplicationError

func StringToDate

func StringToDate(date string) (time.Time, *ApplicationError)

func TechnicalErrorWithCodeAndMessage

func TechnicalErrorWithCodeAndMessage(code, message string) *ApplicationError

func TechnicalErrorWithError

func TechnicalErrorWithError(err error) *ApplicationError

func ValidateStruct added in v0.0.4

func ValidateStruct(i interface{}) *ApplicationError

func (*ApplicationError) Error

func (m *ApplicationError) Error() string

func (*ApplicationError) GetStatus

func (m *ApplicationError) GetStatus() int

func (*ApplicationError) IsBusinessError

func (m *ApplicationError) IsBusinessError() bool

func (*ApplicationError) IsTechnicalError

func (m *ApplicationError) IsTechnicalError() bool

type Config

type Config struct {
	Log struct {
		Ignore     bool
		Level      string
		EnableJSON bool
		Metric     bool
	}
	AppConfig any `yaml:"config" mapstructure:"config" json:"config"`
}

type FlagDefinition added in v0.0.5

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

type ITaskRunner added in v0.0.5

type ITaskRunner interface {
	Execute()
}

type MetricLogHook

type MetricLogHook struct {
	LogEvent metric.Int64Counter
}

LevelHook applies a different hook for each level.

func (*MetricLogHook) Init

func (m *MetricLogHook) Init()

func (*MetricLogHook) Run

func (m *MetricLogHook) Run(e *zerolog.Event, level zerolog.Level, message string)

type ServerMetrics

type ServerMetrics struct {
}

func NewServerMetrics

func NewServerMetrics(lc fx.Lifecycle) *ServerMetrics

type Tracer

type Tracer struct {
	TracerProvider *trace.TracerProvider
}

func NewTracer added in v0.0.3

func NewTracer(lc fx.Lifecycle) *Tracer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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