helpers

package module
v0.0.0-...-74031c7 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2025 License: Apache-2.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

View Source
const ResultKey = "result"

Variables

This section is empty.

Functions

func ArrMapToStructList

func ArrMapToStructList[T any](data []map[string]interface{}) ([]T, error)

func JsonForLogs

func JsonForLogs(obj any) string

func MapListToStructList

func MapListToStructList[T any](data []map[string]interface{}) ([]T, error)

func MapListToStructListDynamic

func MapListToStructListDynamic(source []map[string]interface{}, output interface{}) error

func MapToStruct

func MapToStruct[T any](data map[string]interface{}) (*T, error)

func MapToStructDynamic

func MapToStructDynamic(source map[string]interface{}, target interface{}) (interface{}, error)

func MarshalWithoutHTMLEscaping

func MarshalWithoutHTMLEscaping(v any) ([]byte, error)

func SanitizeTimeFields

func SanitizeTimeFields(input interface{}) interface{}

func StructToMap

func StructToMap[T any](data T) (map[string]interface{}, error)

func ToBytes

func ToBytes(i any) ([]byte, error)

func ToMap

func ToMap(t reflect.Type) map[string]interface{}

func ToStructPb

func ToStructPb(obj any) (*structpb.Struct, error)

func TrackExecutionTime

func TrackExecutionTime(t *TimeTrack) func() *TimeTrack

Types

type Response

type Response struct {
	Code      int64   `json:"code,omitempty"`
	Errors    []error `json:"errors,omitempty"`
	RequestID string  `json:"request_id,omitempty"`
	Response  *pb.Response
}

func NewInternalResponse

func NewInternalResponse(ctx context.Context) *Response

func ToInternalResponse

func ToInternalResponse(response *pb.Response) *Response

func (*Response) AddError

func (r *Response) AddError(err error)

func (*Response) GetBegin

func (r *Response) GetBegin() (*pb.BeginResponse, error)

func (*Response) GetCode

func (r *Response) GetCode() int64

func (*Response) GetCommit

func (r *Response) GetCommit() (*pb.CommitTransactionResponse, error)

func (*Response) GetDelete

func (r *Response) GetDelete() (*pb.DeleteResponse, error)

func (*Response) GetErrors

func (r *Response) GetErrors() []string

func (*Response) GetHealth

func (r *Response) GetHealth() (*pb.HealthResponse, error)

func (*Response) GetInsert

func (r *Response) GetInsert() (*pb.InsertResponse, error)

func (*Response) GetRaw

func (r *Response) GetRaw() (*pb.RawResponse, error)

func (*Response) GetRequestID

func (r *Response) GetRequestID() string

func (*Response) GetRollback

func (r *Response) GetRollback() (*pb.RollbackResponse, error)

func (*Response) GetSchema

func (r *Response) GetSchema() (*pb.GetSchemaResponse, error)

func (*Response) GetSelect

func (r *Response) GetSelect() (*pb.SelectResponse, error)

func (*Response) GetUpdate

func (r *Response) GetUpdate() (*pb.UpdateResponse, error)

func (*Response) HasErrors

func (r *Response) HasErrors() bool

func (*Response) Set

func (r *Response) Set() *pb.Response

func (*Response) SetBegin

func (r *Response) SetBegin(begin *pb.BeginResponse) *pb.Response

func (*Response) SetCommit

func (r *Response) SetCommit(commit *pb.CommitTransactionResponse) *pb.Response

func (*Response) SetDelete

func (r *Response) SetDelete(delete *pb.DeleteResponse) *pb.Response

func (*Response) SetHealth

func (r *Response) SetHealth(health *pb.HealthResponse) *pb.Response

func (*Response) SetInsert

func (r *Response) SetInsert(insert *pb.InsertResponse) *pb.Response

func (*Response) SetRaw

func (r *Response) SetRaw(raw *pb.RawResponse) *pb.Response

func (*Response) SetRollback

func (r *Response) SetRollback(rollback *pb.RollbackResponse) *pb.Response

func (*Response) SetSchema

func (r *Response) SetSchema(schema *pb.GetSchemaResponse) *pb.Response

func (*Response) SetSelect

func (r *Response) SetSelect(selectResp *pb.SelectResponse) *pb.Response

func (*Response) SetUpdate

func (r *Response) SetUpdate(update *pb.UpdateResponse) *pb.Response

func (*Response) String

func (r *Response) String() string

func (*Response) ToJSON

func (r *Response) ToJSON() string

func (*Response) ToMap

func (r *Response) ToMap() map[string]interface{}

type SchemaManager

type SchemaManager struct {
	Schemas map[string]func() any
}

func NewSchemaManager

func NewSchemaManager() *SchemaManager

func (*SchemaManager) GetSchema

func (sm *SchemaManager) GetSchema(name string) (any, bool)

func (*SchemaManager) MigrateSchemas

func (sm *SchemaManager) MigrateSchemas(db *gorm.DB) error

func (*SchemaManager) RegisterSchema

func (sm *SchemaManager) RegisterSchema(name string, schemaFunc func() any)

type TimeTrack

type TimeTrack struct {
	Start time.Time
	End   time.Time
}

Jump to

Keyboard shortcuts

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