Skip to content

Technical Design

Daniel Renaud edited this page Oct 18, 2019 · 4 revisions

Technical Design

Introduction

Extension amazon-event-bridge is supposed to add basic Event Bridge integration capabilities to Magento by providing a set of service contracts which provide access to AWS API. All of the logic is already implemented in a AWS SKD for PHP allowing the extension to take it into advantage and only introduce service contracts and adapters to the existing Magento services.

Contracts

Minimal implementation of the service contracts for this purpose may be composed just from couple of interfaces:

  • event data container, allowing storing of arbitrary data and all of the required event attributes
interface EventInterface
{
    /**
     * Get the event bus name
     *
     * The event bus that will receive the event
     *
     * @return string
     */
    public function getEventBusName(): ?string;

    /**
     * Get event resources
     *
     * AWS resources, identified by Amazon Resource Name (ARN), that the event primarily concerns
     *
     * @return string[]
     */
     public function getResources(): ?array;

    /**
     * Get event detail
     *
     * Data payload of the event
     *
     * @return array
     */
    public function getDetail(): ?array;

    /**
     * Get event detail type
     *
     * Free-form string used to decide which fields to expect in the event detail
     *
     * @return string
     */
    public function getDetailType(): ?string;

    /**
     * Get event source
     *
     * The source of the event
     *
     * @return string
     */
    public function getSource(): ?string;

    /**
     * Get time of event
     *
     * The timestamp of the event. string|DateTime or anything parsable by strtotime
     *
     * @return string
     */
    public function getTime(): ?string;
}
  • service handling dispatching of the events.
interface PutEventsInterface
{
    /**
     * @param EventInterface[] $events
     * @return void
     */
    public function putEvents(array $events): void
}

Theory of Operation

Implementation for the service contracts should provide a facade over AWS SDK for PHP seamlessly integrating common Magento practices with the SDK capabilities. Event objects may be created by a factory, taking into account all of the required fields and their values based on xml configuration of the event bus. Event dispatching service should handle authentication with AWS API and transport data by proxying it to the contracts present in the SDK.

Further considerations

  1. XML configuration must be designed and declared for the Event Bus client and events
  2. Factory may be designed to construct clients and event objects
  3. Multiple types of clients may be implemented on top of the described service contract, e. g. synchronous and async.
Clone this wiki locally