Giter Club home page Giter Club logo

wolnosciowiec-notification's Introduction

Wolnościowiec Notification

Deploy Docker Build Status MicroBadger Layers

API gateway for sending notifications, with queue support.

Features:

  • Ready to use application that sends notifications with just one REST call
  • Queue support (Redis or SQLite3)
  • Sync and async interfaces
  • Builtin Twitter and Facebook support
  • Easily extensible (Queue storage could be easily added and switched, also the senders could be easily added eg. support for mail sending)
  • Written in Symfony 3 should be understandable for most PHP programmers

How it works?

The application is taking as input ANY TYPE of message that implements the Message interface. Message interface is a definition of minimum required fields and a mark for a class that its an input message.

Messenger is a message sending implementation that is able to handle specific message types, and possibly the basic message type.

To create a custom message format you have to:

  1. Create a new class that implements MessageInterface or extends Message
  2. Register it in your notification.yml under allowed_entities section
  3. Make create a Messenger, in other words a MESSAGE HANDLER, A SENDER that implements MessengerInterface
  4. Register your Messenger in notification.yml under enabled_messengers section, add the configuration in messengers section

To retrieve a configuration in your Messenger you have to inject the MessengerConfigurationProvider service using the container

Installation

cp app/config/notification.yml.dist app/config/notification.yml
nano app/config/notification.yml
composer install --dev

Configuration

Edit the configuration in app/config/notification.yml (if it does not exists then just create the file)

notification:
    queue: "notificationbundle.queue.redis"
    queue_parameters:
        scheme: tcp
        host: localhost
        port: 6379

    allowed_entities:
        Message: "NotificationBundle\\Model\\Entity\\Message"

    enabled_messengers:
        "notificationbundle.messenger.twitter":
            class: NotificationBundle\Messenger\TwitterMessenger
            groups:
                - short_content_update_notification

    messengers:
        twitter:
            consumer_key: aaa
            consumer_secret: bbb
            access_token: ccc
            access_token_secret: ddd

        facebook:
            app_id: xxx
            app_secret: yyy

Usage

Example HTTP request:

POST /message/queue/add?message_type=Message

{
    "message":    "This will go on to Twitter",
    "group_name": "short_content_update_notification",
    "could_be_truncated": true
}
GET /message/queue/process

Docker

  1. Use wolnosciowiec/wolnosciowiec-notification image as your base image, extend it by adding a configuration file "notification.yml" to the app/config directory. The image is exposing 9000 and 80 port, the first is for PHP-FPM 7.x and the second from configured nginx.

  2. Configure rest of things with environment variables

See the list of env variables

You can attach a single redis instance as a storage, then scale notifications service with Docker Swarm or Kubernetes easily. Accessibility of nginx in a container gives ability to use service discovery such as Traefik.

wolnosciowiec-notification's People

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

morristech

wolnosciowiec-notification's Issues

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.