Skip to main content

Default settings and options

Configure default settings

You can efficiently process messages by configuring publish and receive (pull) settings.

Publish settings
ItemDescription
DelayThresholdSends publish requests at defined intervals
- Default: 100ms
CountThresholdSends messages in batch when the specified count is reached
- Default: 100
NumGoroutinesLimits the number of concurrently running goroutines
- Default: 2
- Max: 10
TimeoutTimeout duration for publish requests
- Default: 60s
FlowControlSettingsControls the publish rate through flow control settings
Receive settings
ItemDescription
NumGoroutinesLimits the number of concurrently running goroutines
- Default: 2
- Max: 10
FlowControlSettingsControls the receive rate through flow control settings
Flow control settings
ItemDescription
MaxOutstandingMessagesMaximum number of messages that can be held in the internal buffer
- Default: 1000
MaxOutstandingBytesMaximum size of messages that can be held in the internal buffer
- Default: 1G
LimitExceededBehaviorBehavior when the threshold is exceeded
SignalError: Returns an error
Block (Default): Waits until request can proceed without exceeding limits
 ⚠️ Useful in batch processing scenarios where individual request latency is not critical
Ignore: Disables flow control

Retry

When gRPC calls return specific error codes, retry attempts are made based on configured retry options. The default retry codes and settings per API are listed below.

Retry error status codes

Refer to gRPC status code documentation for more information.

CodeDescription
CANCELLEDCall was cancelled (usually by the client)
UNKNOWNUnknown error, possibly due to unexpected status from a different address
Also occurs when the API does not return specific error info
DEADLINE_EXCEEDEDDeadline expired before the call completed
NOT_FOUNDRequested entity not found
RESOURCE_EXHAUSTEDResource quota exceeded or system storage full
ABORTEDOperation aborted due to concurrency conflict (e.g., failed sequencer check)
INTERNALInternal server error
UNAVAILABLEService is currently unavailable
Retry configuration options
ItemDescription
InitialInitial delay before first retry
- Adjusted by Multiplier
MultiplierNext retry delay = previous retry delay × Multiplier
MaxMaximum retry delay
⚠️ Multiplier cannot increase delay beyond this limit
Publisher retry default setting
APIRetry codeDescriptionRetry setting
create topic14UNAVAILABLE• Initial: 100ms
• Multiplier: 1.3
• Max: 60s
get topic14UNAVAILABLE-
list topics14UNAVAILABLE-
list topic subscriptions14UNAVAILABLE-
update topic14UNAVAILABLE-
delete topic14UNAVAILABLE-
publish1CANCELLED-
4DEADLINE_EXCEEDED-
8RESOURCE_EXHAUSTED-
13INTERNAL-
14UNAVAILABLE-
Subscriber retry default setting
APIRetry codeDescriptionRetry setting
create subscription14UNAVAILABLE• Initial: 100ms
• Multiplier: 1.3
• Max: 60s
get subscription14UNAVAILABLE-
list subscriptions14UNAVAILABLE-
seek14UNAVAILABLE-
update subscription14UNAVAILABLE-
delete subscription14UNAVAILABLE-
modify ack deadline14UNAVAILABLE-
acknowledge14UNAVAILABLE-
pull14UNAVAILABLE-
streaming pull4DEADLINE_EXCEEDED-
8RESOURCE_EXHAUSTED-
13INTERNAL-
14UNAVAILABLE-
Example: Custom retry configuration
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, cfg, opts...)

Logging

You can record statistical logs of request and response results (success/failure) from Publish and StreamingPull operations.

  • When a time interval is configured, the number of successful and failed publish and pull attempts is logged periodically.
  • To view logs, the logging level must be set to info or higher.

The logger supports the following configuration options:

ItemDescription
LevelLog level
- Default: Panic
OutputLog output destination
- Default: os.Stdout
StatLogIntervalInterval at which logs are written
Logging example
conf := &ClientConfig{
LogOptions: &LogOptions{
Level: "info",
Output: os.Stdout,
StatLogInterval: 1 * time.Second
}
}
client, err := NewClientWithConfig(ctx, domainID, projectID, conf, opts...)