KubeMQ
Client SDKsC++Reference

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.

Status

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";
}
MethodReturn TypeDescription
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

Sentinel Errors

ConstantDescription
kErrClientClosedClient has been closed
kErrNotImplementedOperation is not implemented
kErrValidationInput validation failed

StatusOr<T>

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";
}
MethodDescription
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()

BadStatusAccess

Exception thrown by StatusOr::value() when the StatusOr holds an error. Callers should check ok() before calling value().

ErrorCode

CodeDescription
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

Domain Error Types

BufferFullError

Indicates the reconnect buffer is full and messages were discarded.

MethodDescription
buffer_size()Buffer capacity
queued_count()Messages that were queued

StreamBrokenError

Indicates a stream was broken with unacknowledged messages.

MethodDescription
unacknowledged_ids()Vector of unacked message IDs

TransportError

Wraps a transport-level (gRPC) failure.

MethodDescription
operation()The operation that failed
cause()The underlying Status error

HandlerError

Indicates a subscription callback handler failed.

MethodDescription
handler()The handler name that failed
cause()The underlying Status error

Constants

Channel Types

ConstantValueDescription
kChannelTypeEvents"events"Fire-and-forget events
kChannelTypeEventsStore"events_store"Persistent events
kChannelTypeCommands"commands"Synchronous commands
kChannelTypeQueries"queries"Synchronous queries
kChannelTypeQueues"queues"Guaranteed delivery queues

Default Timeouts

ConstantValueDescription
kDefaultConnectionTimeout10sInitial connection timeout
kDefaultSendTimeout5sSend operation timeout
kDefaultRPCTimeout10sCommand/query timeout
kDefaultQueuePollTimeout30sQueue poll timeout
kDefaultDrainTimeout5sDrain timeout on close
kDefaultKeepaliveTime10sgRPC keepalive interval
kDefaultKeepaliveTimeout20sgRPC keepalive timeout
kDefaultCallbackTimeout30sMax callback duration

Size Limits

ConstantValueDescription
kDefaultMaxReceiveMessageSize4 MBMax inbound message
kDefaultMaxSendMessageSize100 MBMax outbound message
kDefaultSubscriptionBufferSize10Per-subscription buffer
kDefaultMaxConcurrentCallbacks1Max concurrent callbacks

See Also

Was this page helpful?

On this page