Default settings and options
Default settings
Configure publish and receive (pull) settings to handle messages efficiently.
Publish Settings
Item | Description |
---|---|
DelayThreshold | Sends a publish request to the server at the specified interval. - Default: 100ms . |
CountThreshold | Collects and sends messages in batches of the specified size. - Default: 100 . |
NumGoroutines | Limits the number of concurrently running Goroutines. - Default: 2 .- Max: 10 . |
Timeout | Sets the timeout for server requests. - Default: 60s . |
FlowControlSettings | Controls publishing rate through flow control. |
Receive Settings
Item | Description |
---|---|
NumGoroutines | Limits the number of concurrently running Goroutines. - Default: 2 .- Max: 10 . |
FlowControlSettings | Controls publishing rate through flow control. |
FlowControl Settings
Item | Description |
---|---|
MaxOutstandingMessages | Specifies the maximum number of messages that can be processed in the internal buffer. - Default: 1000 . |
MaxOutstandingBytes | Specifies the maximum size of messages that can be processed in the internal buffer. - Default: 1G . |
LimitExceededBehavior | Defines behavior when limits are exceeded. • SignalError : Returns an error.• Block (Default): Waits until requests can be made without exceeding the limit (*useful for batch processing where individual request latency is not critical).• Ignore : Disables flow control. |
Retry
When a gRPC call encounters an error corresponding to a specified status, it will retry the call based on the configured retry settings. Each API includes default retry responses and settings as described below.
Retry error status codes
For more details, refer to GRPC Github.
Item | Description |
---|---|
CANCELLED | The call was canceled, usually by the client. |
UNKNOWN | Unknown error, for example, a response from another address that is not defined for this address. - Also applies when the API does not provide detailed error information. |
DEADLINE_EXCEEDED | The deadline expired before the operation completed. |
NOT_FOUND | Some requested entity (e.g., file or path) was not found. |
RESOURCE_EXHAUSTED | Resources are exhausted (e.g., insufficient per-user quota or insufficient disk space). |
ABORTED | Operation aborted, often due to concurrency issues such as sequencer check failure or mid-transaction conflicts. |
INTERNAL | Internal server error. |
UNAVAILABLE | The service is currently unavailable. |
Retry settings
Item | Description |
---|---|
Initial | The delay before the first retry. - Adjusted based on the Multiplier value. |
Multiplier | Next retry delay = Previous retry delay * Multiplier. |
Max | Sets a limit on retry delay. ⚠️ Multiplier cannot cause retry delay to exceed this value. |
Publisher Retry Default Setting
API | Retry code | Description | Retry setting |
---|---|---|---|
create topic | 14 | UNAVAILABLE | • Initial : 100ms • Multiplier : 1.3 • Max : 60s |
get topic | 14 | UNAVAILABLE | |
list topics | 14 | UNAVAILABLE | |
list topic subscriptions | 14 | UNAVAILABLE | |
update topic | 14 | UNAVAILABLE | |
delete topic | 14 | UNAVAILABLE | |
publish | 1 | CANCELLED | |
4 | DEADLINE_EXCEEDED | ||
8 | RESOURCE_EXHAUSTED | ||
13 | INTERNAL | ||
14 | UNAVAILABLE |
Subscriber Retry Default Settings
API | Retry code | Description | Retry setting |
---|---|---|---|
create subscription | 14 | UNAVAILABLE | • Initial : 100ms • Multiplier : 1.3 • Max : 60s |
get subscription | 14 | UNAVAILABLE | |
list subscriptions | 14 | UNAVAILABLE | |
seek | 14 | UNAVAILABLE | |
update subscription | 14 | UNAVAILABLE | |
delete subscription | 14 | UNAVAILABLE | |
modify ack deadline | 14 | UNAVAILABLE | |
acknowledge | 14 | UNAVAILABLE | |
pull | 14 | UNAVAILABLE | |
streaming pull | 4 | DEADLINE_EXCEEDED | |
8 | RESOURCE_EXHAUSTED | ||
13 | INTERNAL | ||
14 | UNAVAILABLE |
example.
cfg := &pubsub.ClientConfig{
PublisherCallOptions: &api.PublisherCallOptions{
Publish: []option.CallOption{
option.WithRetryOptions(
option.WithCodes(codes.ResourceExhausted),
option.WithBackoff(option.Backoff{
Initial: 100 * time.Millisecond,
Max: 30000 * time.Millisecond,
Multiplier: 1.20,
})),
},
},
SubscriberCallOptions: &api.SubscriberCallOptions{
StreamingPull: []option.CallOption{
option.WithRetryOptions(
option.WithCodes(codes.ResourceExhausted),
option.WithBackoff(option.Backoff{
Initial: 100 * time.Millisecond,
Max: 60000 * time.Millisecond,
Multiplier: 1.30,
})),
},
},
}
client, err := NewClientWithConfig(ctx, domainID, projectID, conf, opts...)
Logging
Logs for requests and responses (success/failure) in Publish and StreamingPull can be recorded for statistical purposes.
- If a time interval is configured, the success/failure counts for publish and pull operations are logged at each interval.
- To view the logs, the log level must be set to
info
or higher.
The following default values can be configured for the logger:
Item | Description |
---|---|
Level | Log level - Default: Panic . |
Output | Log output - Default: os.Stdout . |
StatLogInterval | Time interval for recording logs. |
Logging example
conf := &ClientConfig{
LogOptions: &LogOptions{
Level: "info",
Output: os.Stdout,
StatLogInterval: 1 * time.Second
}
}
client, err := NewClientWithConfig(ctx, domainID, projectID, conf, opts...)