StreamClient

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

The API for the Streaming Service.

__init__(config, **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) -- (optional) The endpoint of the service to call using this client. For example https://iaas.us-ashburn-1.oraclecloud.com. If this keyword argument is not provided then it will be derived using the region in the config parameter. You should only provide this keyword argument if you have an explicit need to specify a service endpoint.
  • timeout (float or tuple(float, float)) -- (optional) The connection and read timeouts for the client. The default is that the client never times out. 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)

Commits processed offsets to consumer group state. 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 for which the group is committing offsets.
  • 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)

Extends the reservation timeout on partitions reserved by the provided cursor. 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 for which the group is committing offsets.
  • 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 for the specified stream. A cursor is used to consume a stream. 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 to create a cursor for.
  • 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 for the specified stream. A cursor is used to consume a stream. Creates a group-cursor.

Parameters:
  • stream_id (str) -- (required) The OCID of the stream to create a cursor for.
  • 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. Returns the current state of a consumer group.

Parameters:
  • stream_id (str) -- (required) The OCID of the stream, on which the group is operating.
  • 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)

Gets messages from a stream. 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 to get messages from.
  • 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)

Puts messages in a stream. 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 where you want to put messages.
  • 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 committed location of a group on a stream. 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, on which the group is operating.
  • 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