Options
All
  • Public
  • Public/Protected
  • All
Menu

Class EventGridConsumer

Package version

EventGridConsumer is used to aid in processing events delivered by EventGrid. It can deserialize a JSON encoded payload of either a single event or batch of events as well as be used to convert the result of JSON.parse into an EventGridEvent or CloudEvent like object.

Unlike normal JSON deseralization, EventGridConsumer does some additional conversions:

  • The consumer parses the event time property into a Date object, for ease of use.
  • When deserializing an event in the CloudEvent schema, if the event contains binary data, it is base64 decoded and returned as an instance of the Uint8Array type.
  • The data payload from system events is converted to match the interfaces this library defines.

When constructing an EventGridConsumer, a map of event types to custom deserializers may be provided. When deserializing, if a custom deserializer has been registered for a given event type, it will be called with the data object. The object this deserializer returns will replace the existing data object.

Hierarchy

  • EventGridConsumer

Index

Constructors

constructor

Properties

customDeserializers

customDeserializers: Record<string, CustomEventDataDeserializer>

Methods

deserializeCloudEvents

  • deserializeCloudEvents(encodedEvents: string): Promise<CloudEvent<unknown>[]>
  • deserializeCloudEvents(encodedEvents: object): Promise<CloudEvent<unknown>[]>
  • Deserializes events encoded in the Cloud Events 1.0 schema.

    Parameters

    • encodedEvents: string

      the JSON encoded representation of either a single event or an array of events, encoded in the Cloud Events 1.0 Schema.

    Returns Promise<CloudEvent<unknown>[]>

  • Deserializes events encoded in the Cloud Events 1.0 schema.

    Parameters

    • encodedEvents: object

      an object representing a single event, encoded in the Cloud Events 1.0 schema.

    Returns Promise<CloudEvent<unknown>[]>

deserializeEventGridEvents

  • deserializeEventGridEvents(encodedEvents: string): Promise<EventGridEvent<unknown>[]>
  • deserializeEventGridEvents(encodedEvents: object): Promise<EventGridEvent<unknown>[]>
  • Deserializes events encoded in the Event Grid schema.

    Parameters

    • encodedEvents: string

      the JSON encoded representation of either a single event or an array of events, encoded in the Event Grid Schema.

    Returns Promise<EventGridEvent<unknown>[]>

  • Deserializes events encoded in the Event Grid schema.

    Parameters

    • encodedEvents: object

      an object representing a single event, encoded in the Event Grid schema.

    Returns Promise<EventGridEvent<unknown>[]>

Generated using TypeDoc