zcloud.pubsub.messaging module

class zcloud.pubsub.messaging.MessageContainer(payload, project_id, topic_name, schema_name, message_type='event', message_subject=None, priority='low', metadata=None, attributes=None, parent_envelope=None)[source]

Bases: object

Wrapper to handle message schema, defaults for pub/sub queue

send_message()[source]

Send a message to the pub/sub topic

Return type:

None

zcloud.pubsub.messaging.get_schema(*args, **kwargs)[source]

Get the schema for the message, default to columna

can be used in test mode as well

Return type:

dict

zcloud.pubsub.messaging.unpack_envelope(envelope, project_id, schema_name)[source]

Unpacks a Pub/Sub envelope containing an Avro-encoded message using the specified schema.

Parameters:
  • envelope (dict) – The Pub/Sub message envelope containing base64-encoded data

  • project_id (str) – GCP project ID where the schema is located

  • schema_name (str) – Name of the schema to use for decoding

Returns:

Decoded message contents

Return type:

dict

Raises:
  • ValueError – If envelope is missing required data

  • Exception – If schema cannot be retrieved or message cannot be decoded