Giter Site home page Giter Site logo

prooph / micro Goto Github PK

View Code? Open in Web Editor NEW
54.0 16.0 7.0 320 KB

Functional prooph for microservices

Home Page: http://getprooph.org

License: BSD 3-Clause "New" or "Revised" License

PHP 100.00%
prooph event-sourcing cqrs eventsourcing microservice php ddd functional

micro's Introduction

prooph-micro

[Experimental] Functional prooph for microservices

Installation

composer install

Example usage

php examples/register_and_change_username.php

Run example snapshotter

php examples/user_snapshotter.php

prooph Microservices in Action

prooph/micro-do

Support

Contribute

Please feel free to fork and extend existing or add new plugins and send a pull request with your changes! To establish a consistent code quality, please provide unit tests for all your changes and may adapt the documentation.

License

Released under the New BSD License.

micro's People

Contributors

basz avatar codeliner avatar oqq avatar prolic avatar vmetcalfe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

micro's Issues

Add message validator

Let's check a message upfront and return early, when it's not confirming to the requirements

add micro command for composer

Requirements:

  • able to run composer update for a single microservice
  • able to run composer install for a single microservice
  • able to run composer update for all microservices
  • able to run composer install for all microservices

Example docker-command:

docker run --rm -it --volume $(dirname $SSH_AUTH_SOCK):$(dirname $SSH_AUTH_SOCK) -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK --volume $(pwd):/app --volume $(pwd)/../../packages:/packages prooph/composer:7.1 install

As you can see, this docker command is quite long and hard to remember, therefore we want to provide shortcuts for micro.

Things to note:

Each php-service can use a different image and PHP version (f.e. 5.6 on service1 and 7.1 on service2). Therefore the correct prooph/composer images with the same php version has to be chosen correctly by this command.

Syntax suggestion

./bin/micro micro:composer:update service1
./bin/micro micro:composer:update --all
./bin/micro micro:composer:install service2
./bin/micro micro:composer:install --all

TypeError on example

php examples/register_and_change_username.php

Gives an TypeError. Not sure if that is intentional cause running an InvalidCommand

TypeError
"Return value of Prooph\\Common\\Messaging\\DomainMessage::messageName() must be of the type string, null returned"

Add akka-like messaging

from the chat:

an aggregate talks to the process manager (or another aggregate) directly, no magic wiring in the background. that's a huge difference, and I like the explicitness - would like to have something like this in micro - thoughts?

Remove AmqpReducer

With #23 publishing was removed as step of the micro pipeline, so it is left to the user how to publish. Hence, we should remove the AmqReducer to not couple micro to a specific message queue

Version vs. event no problem with snapshots

We have a larger problem maybe with the new snapshot implementation in general. See this line: https://github.com/prooph/micro/blob/master/src/SnapshotReadModel.php#L79

This is wrong. You cannot query the event position using the version of the aggregate because they are not the same.
We cannot use the aggregate version to query missing events from the event stream.

See here: https://github.com/prooph/micro/blob/master/src/Kernel.php#L81
At the moment information from snapshot store is not used but how can we change that?
We would need to store the event position along with the snapshot but we don't have this information available in the message.

Any ideas @prolic

[Question] Should we remove state and snapshots?

While writing the Event Sourcing part of our walk-through guide I noticed that it is difficult to explain why we pass state to an aggregate function. A few questions came to mind: Where does the state come from (of course I know the answer but it requires a lot of explanation)? Why don't we work with the history instead?

I did a short research and found this excellent blog post by @mathiasverraes. I read the post long time ago but my focus was on object oriented ES and not the fp way.

Mathias uses f(history, command) => events to describe an aggregate function.

Our definition looks a bit different atm: f(state, command) => newState // events

It allows us to work with state snapshots and the aggregate function can inspect state to verify that command can be processed. But the aggregate function could also inspect history instead.

If we pass history and only return events our aggregate functions become even more simple. We no longer need the apply method as this would be only part of a projection. The aggregate can iterate history and filter events with required information. As long as the history of a single aggregate is not too big it would work quite well.

Remove upstream definition from nginx site config

The upstream definition is only needed to add multiple server for one upstream. But this should be handled by an load balancer who resolves the Docker service name. This is done by Docker Swarm or an AWS Elastic Load Balancer. Does we really need it? But I have to check if the resolver definition is needed then, this would be a problem.

Change command handlers

function (callable $stateResolver, Command $command): Events[]

Pros:

  • more explicit
  • no loading of state / history events, when not needed

refers to #34

Add pdo env to php images if they are depended

Scenario

  1. User creates a postgres/mysql database (./bin/micro micro:setup:postgres)
  2. User creates a php-service and selects this postgres database as dependend (./bin/micro micro:setup:php-service)

Feature Request

All MySQL and PostgreSQL databases created by micro cli commands, have a label prooph-pdo:true in the docker-compose.yml.

When the php-service is created, it should check for the prooph-pdo label and add the following environment variables to the php-image:

PROOPH_PDO_DSN=pgsql:host=postgres port=5432 dbname=micro_do
PROOPH_PDO_USER=postgres
PROOPH_PDO_PWD=

with the values of host name, port number, dbname, user & password taken from the docker-compose.yml file

Goal

In the PHP service you can create a database connection very easy with the given environment variables, so no additonal config is required for this service.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.