level51/cqrs-utils

Multi-Datastore CQRS utilities for SilverStripe

Installs: 398

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 0

Open Issues: 2

Type:silverstripe-module

dev-develop 2017-11-08 00:00 UTC

This package is auto-updated.

Last update: 2024-10-22 13:20:20 UTC


README

Utility Module for implementing the CQRS workflow within a SilverStripe application.

⚠️ This is work in progress and not ready to use/play around with at all! We are just testing this in a project and will deliver a stable build as soon as we have reached a sufficient amount of added value.

Read Payload Manifests

Read Payload Manifests defines the data to be stored on a class basis.

Example Manifest ($read_payload):

class MyObject extends DataObject {

    private static $db = [
        'Title' => 'Varchar',
        'Teaser => 'Text',
        'Content => 'HTMLText'
    ];
    
    private static $has_many = [
        'Categories' => Category::class
    ];
    
    private static $read_payload = [
        'ID',                         // required
        'Title'      => 'CoolTitle'   // required, maps to "CoolTitle()"
        'Teaser'     => false,        // not required
        'Content'    => true,         // required (non-shorthand)
        'Author',                     // required (method value)
        'Categories' => true,         // required recursive relation table
        'Tags'       => [             // not required, maps to "getMyTags()"
            'required' => false,
            'mapping' => 'getMyTags'
        ]
    ];
    
    public function CoolTitle() { ... }
    
    public function Author() { ... }
    
    public function getMyTags() { ... }
}

Handler

Redis

Additional Requirements

  • ext-redis: PHP Redis extension

Example Config

CustomDataObject:
  extensions:
    - CQRSExtension('ID', ['store' => 'RedisPayloadStoreHandler', 'db' => 1])

# Optional, defaults to the values below
RedisPayloadStoreHandler:
  host: 127.0.0.1
  port: 6379
  default_db: 0	

MongoDB

Additional Requirements

Example Config

CustomDataObject:
  extensions:
    - CQRSExtension('ID', ['store' => 'MongoPayloadStoreHandler', 'db' => 'DB_NAME', 'collection' => 'COLLECTION_NAME'])

# Optional, defaults to the values below
MongoPayloadStoreHandler:
  host: 127.0.0.1
  port: 27017	

Elasticsearch

Additional Requirements

Example Config

CustomDataObject:
  extensions:
    - CQRSExtension('ID', ['store' => 'ElasticsearchPayloadStoreHandler', 'index' => 'INDEX_NAME'])

# Optional, defaults to localhost:9200
ElasticsearchPayloadStoreHandler:
  hosts:
    - localhost:9200
    - { host: elastic.domain.tld, port: 443, scheme: https, user: USERNAME, pass: PASS }

Maintainer