exec

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package exec holds the reduced public execution-context contract for Datly runtimes.

The stable core is the generic execution/observability payload:

  • Context
  • ContextKey
  • WithContext / GetContext
  • New(...) plus its generic options

Explicit HTTP construction and logging-preparation helpers may remain public for compatibility, but they are not the governing center of the package.

Index

Constants

This section is empty.

Variables

View Source
var ContextKey = contextKey("xdatly_exec_context")

Functions

func WithContext

func WithContext(ctx context.Context, execCtx *Context) context.Context

WithContext attaches one execution context to ctx under the public ContextKey.

Types

type Context

type Context struct {
	Method     string            `json:"method,omitempty"`
	URI        string            `json:"uri,omitempty"`
	StatusCode int               `json:"statusCode,omitempty"`
	Status     string            `json:"status,omitempty"`
	Error      string            `json:"error,omitempty"`
	ElapsedMs  int               `json:"elapsedMs,omitempty"`
	StartTime  time.Time         `json:"startTime,omitempty"`
	Header     map[string]string `json:"header,omitempty"`
	Metrics    response.Metrics  `json:"metrics,omitempty"`
	TraceID    string            `json:"traceId,omitempty"`
	Trace      *tracing.Trace    `json:"-"`
	// contains filtered or unexported fields
}

func GetContext

func GetContext(ctx context.Context) *Context

func New

func New(options ...Option) *Context

New creates a generic execution context without assuming any specific transport. Callers add transport/runtime details through options.

func NewContext

func NewContext(method string, URI string, header http.Header, version string) *Context

NewContext is the compatibility wrapper over the older HTTP-colored constructor signature. Prefer New(...) for generic callers and NewHTTPContext(...) for explicit HTTP assembly.

func NewHTTPContext

func NewHTTPContext(method string, URI string, header http.Header, version string) *Context

NewHTTPContext builds one execution context from HTTP request metadata. This helper is transport-specific; the stable generic entrypoint is New(...).

func PrepareLogging

func PrepareLogging(ctx *Context, includeSQL bool) (*Context, *tracing.Trace)

PrepareLogging is the compatibility helper that derives audit/trace-ready snapshots from one execution context. It is not the core execution-context contract itself; the stable core remains the Context payload plus its generic constructors and accessors.

func (*Context) AppendMetrics

func (c *Context) AppendMetrics(metric *response.Metric)

func (*Context) Complete

func (c *Context) Complete(end time.Time, err error)

Complete records the canonical invocation boundary. Existing native trace spans are completed; no default trace or span is created by this operation.

func (*Context) SetError

func (c *Context) SetError(err error)

func (*Context) SetValue

func (c *Context) SetValue(key string, value any)

func (*Context) SnapshotForLogging

func (c *Context) SnapshotForLogging() *Context

func (*Context) Value

func (c *Context) Value(key string) (any, bool)

type Option

type Option func(*Context)

Option mutates the generic execution context shape.

func WithHeaders

func WithHeaders(header map[string]string) Option

func WithMethod

func WithMethod(method string) Option

func WithStartTime

func WithStartTime(start time.Time) Option

func WithStatus

func WithStatus(status string) Option

func WithStatusCode

func WithStatusCode(code int) Option

func WithTrace

func WithTrace(trace *tracing.Trace) Option

func WithTraceResource

func WithTraceResource(serviceName, serviceVersion string) Option

func WithURI

func WithURI(uri string) Option

Jump to

Keyboard shortcuts

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