grpc

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PasswordOperationTimeout = 15 * time.Second
	BillingOperationTimeout  = 30 * time.Second
	// AnalyticsOperationTimeout covers the sweeps that read a whole collection — every contracted price, every invoiced line in a window — rather than one record. It sits just under the server's write timeout so the caller gets the API's own timeout error instead of a truncated response.
	AnalyticsOperationTimeout = 25 * time.Second
)

Variables

This section is empty.

Functions

func CallRPC

func CallRPC[T any](
	ctx context.Context,
	tracer trace.Tracer,
	spanName string,
	serviceName string,
	call func(ctx context.Context, opts ...grpc.CallOption) (T, error),
	opts ...RPCOption,
) (T, *apierror.APIError)

CallRPC executes a gRPC call with gateway-specific metadata (identity, idempotency key, API version, request ID) and standard boilerplate (tracing, timeout, error conversion, replayed detection).

Callers within the gateway continue using this function with the same signature — it delegates to rpc.CallRPC after preparing metadata.

func MapProtoPageInfo

func MapProtoPageInfo(ctx context.Context, pi ProtoPageInfo) apiresource.PageInfo

MapProtoPageInfo converts any proto PageInfo into an API resource PageInfo, building relative pagination URLs from the current request URL stored in ctx.

func MapProtoPageInfoForPath

func MapProtoPageInfoForPath(canonicalPath string, pi ProtoPageInfo) apiresource.PageInfo

MapProtoPageInfoForPath is like MapProtoPageInfo but uses an explicit canonical path instead of the current request URL. Use this for sub-object lists embedded in a parent response where the correct pagination URL must point to the sub-resource's own list endpoint. The caller is responsible for expanding any path parameters (e.g. "/v1/catalog/properties/"+propertyID+"/attributes"). Only the cursor query parameter is appended; the parent request's query string is intentionally excluded.

func ParseDateString

func ParseDateString(s string) (time.Time, error)

ParseDateString parses a date string in YYYY-MM-DD format to a time.Time.

func ParseEndDateString

func ParseEndDateString(s string) (time.Time, error)

Parses an inclusive end date (YYYY-MM-DD) as the last microsecond of that day, so rows created during the day still match `<= end`. Microseconds, not nanoseconds — DATETIME(6) stores no more.

func TimestampToTime

func TimestampToTime(t *timestamppb.Timestamp) time.Time

TimestampToTime converts a protobuf timestamp to a time.Time.

func TimestampToTimePtr

func TimestampToTimePtr(t *timestamppb.Timestamp) *time.Time

TimestampToTimePtr converts a protobuf timestamp to a time.Time pointer.

Types

type ProtoPageInfo

type ProtoPageInfo interface {
	GetNextCursor() string
	GetPrevCursor() string
	GetHasNextPage() bool
	GetHasPrevPage() bool
}

ProtoPageInfo is an interface satisfied by all proto-generated PageInfo types across the core, auth, platform, billing, and agent proto packages.

type RPCOption

type RPCOption func(*rpcConfig)

RPCOption configures the behavior of CallRPC. Use the With* functions in this package to obtain option values.

func WithTimeout

func WithTimeout(t time.Duration) RPCOption

WithTimeout overrides the default RPC deadline for this call.

Jump to

Keyboard shortcuts

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