StreamClient

class oci.streaming.StreamClient(config, service_endpoint, **kwargs)

The API for the Streaming Service.

Methods

__init__(config, service_endpoint, **kwargs) Creates a new service client
consumer_commit(stream_id, cursor, **kwargs) Provides a mechanism to manually commit offsets, if not using commit-on-get consumer semantics.
consumer_heartbeat(stream_id, cursor, **kwargs) Allows long-running processes to extend the timeout on partitions reserved by a consumer instance.
create_cursor(stream_id, …) Creates a cursor.
create_group_cursor(stream_id, …) Creates a group-cursor.
get_group(stream_id, group_name, **kwargs) Returns the current state of a consumer group.
get_messages(stream_id, cursor, **kwargs) Returns messages from the specified stream using the specified cursor as the starting point for consumption.
put_messages(stream_id, …) Emits messages to a stream.
update_group(stream_id, group_name, …) Forcefully changes the current location of a group as a whole; reseting processing location of all consumers to a particular location in the stream.
__init__(config, service_endpoint, **kwargs)

Creates a new service client

Parameters:
  • config (dict) – Configuration keys and values as per SDK and Tool Configuration. The from_file() method can be used to load configuration from a file. Alternatively, a dict can be passed. You can validate_config the dict using validate_config()
  • service_endpoint (str) – The endpoint of the service to call using this client. For example https://iaas.us-ashburn-1.oraclecloud.com.
  • timeout (float or tuple(float, float)) – (optional) The connection and read timeouts for the client. The default values are connection timeout 10 seconds and read timeout 60 seconds. This keyword argument can be provided as a single float, in which case the value provided is used for both the read and connection timeouts, or as a tuple of two floats. If a tuple is provided then the first value is used as the connection timeout and the second value as the read timeout.
  • signer (AbstractBaseSigner) –

    (optional) The signer to use when signing requests made by the service client. The default is to use a Signer based on the values provided in the config parameter.

    One use case for this parameter is for Instance Principals authentication by passing an instance of InstancePrincipalsSecurityTokenSigner as the value for this keyword argument

  • retry_strategy (obj) –

    (optional) A retry strategy to apply to all calls made by this service client (i.e. at the client level). There is no retry strategy applied by default. Retry strategies can also be applied at the operation level by passing a retry_strategy keyword argument as part of calling the operation. Any value provided at the operation level will override whatever is specified at the client level.

    This should be one of the strategies available in the retry module. A convenience DEFAULT_RETRY_STRATEGY is also available. The specifics of the default retry strategy are described here.

consumer_commit(stream_id, cursor, **kwargs)

Provides a mechanism to manually commit offsets, if not using commit-on-get consumer semantics. This commits offsets assicated with the provided cursor, extends the timeout on each of the affected partitions, and returns an updated cursor.

Parameters:
  • stream_id (str) – (required) The OCID of the stream.
  • cursor (str) – (required) The group-cursor representing the offsets of the group. This cursor is retrieved from the CreateGroupCursor API call.
  • opc_request_id (str) – (optional) The unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID.
  • retry_strategy (obj) –

    (optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.

    This should be one of the strategies available in the retry module. A convenience DEFAULT_RETRY_STRATEGY is also available. The specifics of the default retry strategy are described here.

    To have this operation explicitly not perform any retries, pass an instance of NoneRetryStrategy.

Returns:

A Response object with data of type Cursor

Return type:

Response

consumer_heartbeat(stream_id, cursor, **kwargs)

Allows long-running processes to extend the timeout on partitions reserved by a consumer instance.

Parameters:
  • stream_id (str) – (required) The OCID of the stream.
  • cursor (str) – (required) The group-cursor representing the offsets of the group. This cursor is retrieved from the CreateGroupCursor API call.
  • opc_request_id (str) – (optional) The unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID.
  • retry_strategy (obj) –

    (optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.

    This should be one of the strategies available in the retry module. A convenience DEFAULT_RETRY_STRATEGY is also available. The specifics of the default retry strategy are described here.

    To have this operation explicitly not perform any retries, pass an instance of NoneRetryStrategy.

Returns:

A Response object with data of type Cursor

Return type:

Response

create_cursor(stream_id, create_cursor_details, **kwargs)

Creates a cursor. Cursors are used to consume a stream, starting from a specific point in the partition and going forward from there. You can create a cursor based on an offset, a time, the trim horizon, or the most recent message in the stream. As the oldest message inside the retention period boundary, using the trim horizon effectively lets you consume all messages in the stream. A cursor based on the most recent message allows consumption of only messages that are added to the stream after you create the cursor. Cursors expire five minutes after you receive them from the service.

Parameters:
  • stream_id (str) – (required) The OCID of the stream.
  • create_cursor_details (CreateCursorDetails) – (required) The information used to create the cursor.
  • opc_request_id (str) – (optional) The unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID.
  • retry_strategy (obj) –

    (optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.

    This should be one of the strategies available in the retry module. A convenience DEFAULT_RETRY_STRATEGY is also available. The specifics of the default retry strategy are described here.

    To have this operation explicitly not perform any retries, pass an instance of NoneRetryStrategy.

Returns:

A Response object with data of type Cursor

Return type:

Response

create_group_cursor(stream_id, create_group_cursor_details, **kwargs)

Creates a group-cursor.

Parameters:
  • stream_id (str) – (required) The OCID of the stream.
  • create_group_cursor_details (CreateGroupCursorDetails) – (required) The information used to create the cursor.
  • opc_request_id (str) – (optional) The unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID.
  • retry_strategy (obj) –

    (optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.

    This should be one of the strategies available in the retry module. A convenience DEFAULT_RETRY_STRATEGY is also available. The specifics of the default retry strategy are described here.

    To have this operation explicitly not perform any retries, pass an instance of NoneRetryStrategy.

Returns:

A Response object with data of type Cursor

Return type:

Response

get_group(stream_id, group_name, **kwargs)

Returns the current state of a consumer group.

Parameters:
  • stream_id (str) – (required) The OCID of the stream.
  • group_name (str) – (required) The name of the consumer group.
  • opc_request_id (str) – (optional) The unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID.
  • retry_strategy (obj) –

    (optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.

    This should be one of the strategies available in the retry module. A convenience DEFAULT_RETRY_STRATEGY is also available. The specifics of the default retry strategy are described here.

    To have this operation explicitly not perform any retries, pass an instance of NoneRetryStrategy.

Returns:

A Response object with data of type Group

Return type:

Response

get_messages(stream_id, cursor, **kwargs)

Returns messages from the specified stream using the specified cursor as the starting point for consumption. By default, the number of messages returned is undefined, but the service returns as many as possible. To get messages, you must first obtain a cursor using the create_cursor() operation. In the response, retrieve the value of the ‘opc-next-cursor’ header to pass as a parameter to get the next batch of messages in the stream.

Parameters:
  • stream_id (str) – (required) The OCID of the stream.
  • cursor (str) – (required) The cursor used to consume the stream.
  • limit (int) – (optional) The maximum number of messages to return. You can specify any value up to 10000. By default, the service returns as many messages as possible. Consider your average message size to help avoid exceeding throughput on the stream.
  • opc_request_id (str) – (optional) The unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID.
  • retry_strategy (obj) –

    (optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.

    This should be one of the strategies available in the retry module. A convenience DEFAULT_RETRY_STRATEGY is also available. The specifics of the default retry strategy are described here.

    To have this operation explicitly not perform any retries, pass an instance of NoneRetryStrategy.

Returns:

A Response object with data of type list of Message

Return type:

Response

put_messages(stream_id, put_messages_details, **kwargs)

Emits messages to a stream. There’s no limit to the number of messages in a request, but the total size of a message or request must be 1 MiB or less. The service calculates the partition ID from the message key and stores messages that share a key on the same partition. If a message does not contain a key or if the key is null, the service generates a message key for you. The partition ID cannot be passed as a parameter.

Parameters:
  • stream_id (str) – (required) The OCID of the stream.
  • put_messages_details (PutMessagesDetails) – (required) Array of messages to put into the stream.
  • opc_request_id (str) – (optional) The unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID.
  • retry_strategy (obj) –

    (optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.

    This should be one of the strategies available in the retry module. A convenience DEFAULT_RETRY_STRATEGY is also available. The specifics of the default retry strategy are described here.

    To have this operation explicitly not perform any retries, pass an instance of NoneRetryStrategy.

Returns:

A Response object with data of type PutMessagesResult

Return type:

Response

update_group(stream_id, group_name, update_group_details, **kwargs)

Forcefully changes the current location of a group as a whole; reseting processing location of all consumers to a particular location in the stream.

Parameters:
  • stream_id (str) – (required) The OCID of the stream.
  • group_name (str) – (required) The name of the consumer group.
  • update_group_details (UpdateGroupDetails) – (required) The information used to modify the group.
  • opc_request_id (str) – (optional) The unique Oracle-assigned identifier for the request. If you need to contact Oracle about a particular request, please provide the request ID.
  • retry_strategy (obj) –

    (optional) A retry strategy to apply to this specific operation/call. This will override any retry strategy set at the client-level.

    This should be one of the strategies available in the retry module. A convenience DEFAULT_RETRY_STRATEGY is also available. The specifics of the default retry strategy are described here.

    To have this operation explicitly not perform any retries, pass an instance of NoneRetryStrategy.

Returns:

A Response object with data of type None

Return type:

Response