eniams/assert-zdd-message-bundle

Assert zdd compliance for asynchronous messages


License
Other

Documentation

Zero Downtime Deployment Message Bundle ✉️

A Symfony Bundle to use when you want to assert that messages used with Message brokers such like RabbitMQ are compliant with the Zero Downtime Deployment.

⚠️ This bundle is still in development (Wait the 1st tag release to use it).

Getting started

Installation

You can easily install API Platform Microservice bundle by composer

$ composer require yousign/zdd-message-bundle

Then, bundle should be registered. Just verify that config\bundles.php is containing :

Yousign\ZddMessageBundle\ZddMessageBundle::class => ['dev' => true, 'test' => true],

Configuration

Once the bundle is installed, you should create a service to configure the messages to assert and how to create them :

# config/services.yaml
  App\Message\MessageConfig: ~
<?php

namespace App\Message;

namespace Eniams\ZddMessageBundle\Message\MessageConfiguratorInterface;

class MessageConfig implements MessageConfiguratorInterface
{
    /**
     * Return the list of messages to assert.
     */
    public function getMessageToAssert(): array
    {
        return [
            App\Message\MyMessage::class,
            App\Message\AnotherMessage::class,
            //...
        ];
    }

    /**
     * If your message contains no scalar value as parameter such like value enums, value object more complex object,
     * you should use this method to return value for each type hint.
     */
    public function getValue(string $typeHint): mixed
    {
        return match ($typeHint) {
            'App\ValueObject\Email' => new App\ValueObject\Email('dummy@email.fr'),
            'App\Enum\MyEnum' => App\Enum\MyEnum::MY_VALUE,
        };
    }
}

Then, you should register it in the configuration (config/packages/yousign.yaml) :

# config/packages/yousign.yaml
  zdd_message:
    configurator: 'App\Message\MessageConfig' # The service that will configure the message, it should implement MessageConfiguratorInterface
    serialized_messages_dir: 'var/serialized_messages' # The directory where the serialized messages will be stored (default: '%kernel.logs_dir%')

Usage

The bundle comes with two commands to assert that your messages are compliant with the Zero Downtime Deployment :

$ bin/console yousign:zdd-message serialize # Serialize the messages in files
$ bin/console yousign:zdd-message validate # Assert that the messages are compliant by deserializing them from files and call the properties.

💡 You should run bin/console yousign:zdd-message serialize with the production version code and bin/console yousign:zdd-message validate with the version code you want to merge.

Example from the version you want to merge:

$ git checkout [production_version]
$ bin/console yousign:zdd-message serialize
$ git checkout - # Go back to the version you want to merge
$ bin/console yousign:zdd-message validate

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

After writing your fix/feature, you can run following commands to make sure that everything is still ok.

# Install dev dependencies
$ composer install

# Running tests and quality tools locally
$ make all

Authors

  • Smaine Milianni - ismail1432 - <smaine(dot)milianni@gmail(dot)com>
  • Simon Mutricy - Inkod - <simon(dot)mutricy@yousign(dot)com>