util

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// APIErrorSourceForge indicates that the error is reported from Forge
	APIErrorSourceForge = "forge"

	// APIErrorInternalServer indicates an unexpected error is reported from Forge
	APIErrorInternalServer = "An unexpected error occurred while processing the request"

	// APIErrorNotFound indicates that the requested path was not found
	APIErrorNotFound = "The requested path was not found"
)
View Source
const (
	// InventoryReceiptInterval is the interval between 2 subsequent inventory receipts
	InventoryReceiptInterval = 3 * time.Minute
	// WorkflowExecutionTimeout is the timeout for a workflow execution
	WorkflowExecutionTimeout = time.Minute * 1
	// WorkflowContextTimeout is the timeout for a workflow context
	WorkflowContextTimeout = time.Second * 50
	// WorkflowContextNewAfterTimeout is the timeout for a new workflow context
	WorkflowContextNewAfterTimeout = time.Second * 5
)

Variables

View Source
var (
	// ErrBadRequest (400) is returned for bad request (validation)
	ErrBadRequest = echo.ErrBadRequest

	// ErrUnauthorized (401) is returned when user is not authorized
	ErrUnauthorized = echo.ErrUnauthorized

	// ErrInternal (500) is returned when an internal server error occurs
	ErrInternal = echo.ErrInternalServerError
)

Functions

func CreateHash

func CreateHash(key string) []byte

CreateHash takes a string and returns SHA 256 digest in a byte array

func DecryptData

func DecryptData(data []byte, passphrase string) []byte

DecryptData provides mechanism to decrypt arguments being passed into workflows

func DefaultHTTPErrorHandler

func DefaultHTTPErrorHandler(err error, c echo.Context)

DefaultHTTPErrorHandler is the default HTTP error handler. It sends a structured error response

NOTE: In case errors happens in middleware call-chain that is returning from handler (handler ran into unrecovered error): When handler has already sent response (ala c.JSON()) and there is error in middleware that is returning from handler, then the error that global error handler received will be ignored because we have already "committed" the response and status code header has been sent to the client.

func EncryptData

func EncryptData(data []byte, passphrase string) []byte

EncryptData provides mechanism to encrypt arguments being passed into workflows so it is not visible within Temporal system

func NewAPIErrorResponse

func NewAPIErrorResponse(c echo.Context, code int, message string, data error) error

NewAPIErrorResponse SENDS an API error response given appropriate params An error is returned to the caller if the send fails.

Types

type APIError

type APIError struct {
	Code    int    `json:"-"`
	Source  string `json:"source"`
	Message string `json:"message"`
	Data    error  `json:"data"`
}

APIError respresents a structured Forge API error

func NewAPIError

func NewAPIError(code int, message string, data error) *APIError

NewAPIError returns an API error given appropriate params

type TracerSpan

type TracerSpan struct {
}

TracerSpan holds span information

func NewTracerSpan

func NewTracerSpan() *TracerSpan

func (*TracerSpan) CreateChildInContext

func (c *TracerSpan) CreateChildInContext(ctx context.Context, spanName string, logger zerolog.Logger) (context.Context, oteltrace.Span)

CreateChildInContext create a child span from specified span name and context

func (*TracerSpan) LoadFromContext

func (c *TracerSpan) LoadFromContext(ctx context.Context) (oteltrace.Span, bool)

LoadFromContext validate and get the spanner from current context

func (*TracerSpan) SetAttribute

func (c *TracerSpan) SetAttribute(cspan oteltrace.Span, kv attribute.KeyValue, logger zerolog.Logger) oteltrace.Span

SetAttribute set key value attribute to current span

Jump to

Keyboard shortcuts

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