Types & Errors Shared types, Status/StatusOr, error codes, and constants -- KubeMQ C++ SDK reference.
The C++ SDK uses explicit Status and StatusOr<T> return types instead of exceptions. All public API methods return these types, requiring callers to check ok() before accessing values.
Represents the result of an operation (success or error).
kubemq ::Status status = client-> SendEvent (event);
if ( ! status. ok ()) {
std ::cerr << "Code: " << static_cast<int> (status. code ())
<< " Message: " << status. message ()
<< " Retryable: " << status. is_retryable () << " \n " ;
}
Method Return Type Description ok()boolTrue if operation succeeded code()ErrorCodeError code (kOk if successful) message()const string&Human-readable error description is_retryable()boolWhether the error is transient operation()const string&Operation that failed channel()const string&Channel associated with error request_id()const string&Request ID associated with error ToString()stringFormatted string representation
Constant Description kErrClientClosedClient has been closed kErrNotImplementedOperation is not implemented kErrValidationInput validation failed
Holds either a value of type T (success) or a Status (error). Use ok() to check state, then value() or operator* to access the value.
auto result = client-> Ping ();
if (result. ok ()) {
std ::cout << "Host: " << result->host << " \n " ;
} else {
std ::cerr << "Error: " << result. status (). message () << " \n " ;
}
Method Description ok()True if holding a value value()Access value (throws BadStatusAccess if error) operator*()Dereference value (undefined behavior if error) operator->()Access value via pointer status()Get the error Status (OK if holding a value) operator bool()Same as ok()
Exception thrown by StatusOr::value() when the StatusOr holds an error. Callers should check ok() before calling value().
Code Description kOkSuccess kTransientRetryable network error (maps to gRPC UNAVAILABLE) kTimeoutOperation timed out kThrottlingRate-limited (maps to gRPC RESOURCE_EXHAUSTED) kAuthenticationAuthentication failed kAuthorizationAuthorization denied kValidationInput validation failed kNotFoundResource not found kFatalUnrecoverable server error (maps to gRPC INTERNAL) kCancellationContext cancelled (maps to gRPC CANCELLED) kBackpressureBuffer full — backpressure applied
Indicates the reconnect buffer is full and messages were discarded.
Method Description buffer_size()Buffer capacity queued_count()Messages that were queued
Indicates a stream was broken with unacknowledged messages.
Method Description unacknowledged_ids()Vector of unacked message IDs
Wraps a transport-level (gRPC) failure.
Method Description operation()The operation that failed cause()The underlying Status error
Indicates a subscription callback handler failed.
Method Description handler()The handler name that failed cause()The underlying Status error
Constant Value Description kChannelTypeEvents"events"Fire-and-forget events kChannelTypeEventsStore"events_store"Persistent events kChannelTypeCommands"commands"Synchronous commands kChannelTypeQueries"queries"Synchronous queries kChannelTypeQueues"queues"Guaranteed delivery queues
Constant Value Description kDefaultConnectionTimeout10s Initial connection timeout kDefaultSendTimeout5s Send operation timeout kDefaultRPCTimeout10s Command/query timeout kDefaultQueuePollTimeout30s Queue poll timeout kDefaultDrainTimeout5s Drain timeout on close kDefaultKeepaliveTime10s gRPC keepalive interval kDefaultKeepaliveTimeout20s gRPC keepalive timeout kDefaultCallbackTimeout30s Max callback duration
Constant Value Description kDefaultMaxReceiveMessageSize4 MB Max inbound message kDefaultMaxSendMessageSize100 MB Max outbound message kDefaultSubscriptionBufferSize10 Per-subscription buffer kDefaultMaxConcurrentCallbacks1 Max concurrent callbacks
Was this page helpful?
Yes No