Skip to content

zus1/psums_aggregator

Repository files navigation

About

Psums project is created to analyze lorem ipsum stream by applying pre defined rules
It is composed of 3 services

  1. Aggregator
  2. Streams
  3. Api

Installation for Psums project

Psums can be installed in two different ways

First is to pull all three services and put them in same directory (each service in its own directory and then all put in same parent directory). Then go to Aggregator directory and run

docker-compose up

This will build up all containers, and those are following:

  • psums_aggregator
  • psums_streams
  • psums_api
  • psums_mysql
  • psums_memcached
After build process i completed (may take a few minutes, depending if you have some images built already) it necessary to bash into aggregator container and run migrations. Psums uses Phinx as migration engine.

docker container exec -it bash psums_aggregator
Yous should be in /var/www/html direcotry, now run migrations

php library/phinx/bin/phinx migrate
Now you should be all set up

Second way is by using Psums composer, you can follow instalation instructions on that repository. It will install production version without access to code base

How to use aggregator

It pretty much uses itself :) Entire process is automated with crons. What aggregator dose is take input streams sent by psums_streams service, parses them and saves word stream to database. Thats the fist part of his code base, saving input streams. Second part is applying pre defined rules to that stream and saving results. And that is, simple right. Those results will then be used by psums_api service to be exposed i format of REST api response.

Aggregator comes with 4 rules out of box. Those are:

  1. compare_vowels: This rule counts number of vowels in words and makes comparison between streams
  2. pook_beef: Funy as it sounds, this rule counts occurrences of pook in first stream and beef in second one, and compares them
  3. pattern: Uses provided patter to check occurrence of symbols in both streams, and compare
  4. match_making: For all words pairs in pattern, checks both steams and tries to first word in first stream and second word in second stream
But is easily extendable with new rules. Process for that is add rule to rules_available table and add rule logic to aggregator project, and that's it. Rules logic is build to be easily extendable

Tracking, whats going on?

Aggregator has multiple logs that will enable you to track whats happening with incoming streams and applying rules. You can check out log_streams table for input streams and log table will keep record of any exceptions if the happen. To si final reports of each cycle look into corns.log in aggregator container. So bash into container, go to /var/log directory and run

tail -f cron.log
This will tail the log and track the inputs in command line.

Results of rules cycles will be saved to rules_results table

If you wish to run included unit test, it can be done by running following command from /var/www/html directory

php vendor/phpunit/phpunit/phpunit tests

And that's all she wroth, for other services docs check their respected repositories, and as always have fun :)

About

Aggregator service for psums

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages