Documentation
¶
Overview ¶
Package idempotencyrpc provides method-aware durable JSON-RPC invocation ownership and bounded response or protocol-error replay.
Index ¶
Constants ¶
const ( // MaxResponseBytes is the largest persisted JSON-RPC response envelope. MaxResponseBytes = 900 * 1024 // MinResponseBytes leaves room for a durable internal-error response. MinResponseBytes = 256 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallResult ¶
type CallResult struct {
Outcome idempotency.Outcome
Response Response
Replayed bool
}
CallResult reports the semantic outcome and any handler response.
type Error ¶
type Error struct {
Code int `json:"code"`
Message string `json:"message"`
Data json.RawMessage `json:"data,omitempty"`
}
Error is a JSON-RPC protocol error that can be durably replayed.
type FingerprintFunc ¶
type FingerprintFunc func(Request) (idempotency.Fingerprint, error)
FingerprintFunc computes canonical business-request identity.
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware durably elects handlers and replays bounded responses.
func New ¶
func New(options Options) (*Middleware, error)
New validates options and constructs JSON-RPC middleware.
func (*Middleware) Call ¶
func (m *Middleware) Call( ctx context.Context, request Request, handler Handler, ) (result CallResult, err error)
Call invokes handler only for a newly acquired or taken-over request.
type Options ¶
type Options struct {
Service *idempotency.Service
Lease time.Duration
MaxResponseBytes int
TransitionTimeout time.Duration
Key KeyFunc
Fingerprint FingerprintFunc
}
Options configures method-aware durable JSON-RPC invocation.
type Request ¶
type Request struct {
Method string
Params json.RawMessage
}
Request contains the business fields used for method-aware idempotency.
type Response ¶
type Response struct {
Result json.RawMessage `json:"result,omitempty"`
Error *Error `json:"error,omitempty"`
}
Response contains exactly one JSON result or protocol error.