khabar

command module
v0.0.0-...-b4989b1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2015 License: Apache-2.0 Imports: 9 Imported by: 0

README

Build Status Gitter

Khabar

Notifications engine.

It means

the latest information; news.

google it

Table of contents

Concept and idea

Channels

Ident or topic

How does it work?

Development

$ go get github.com/codegangsta/gin
$ go get github.com/tools/godep
  • gin is used to to automatically compile files while you are developing
  • godep is used to manage dependencies

Then run

$ mkdir -p $GOPATH/src/github.com/bulletind
$ cd $GOPATH/src/github.com/bulletind
$ git clone https://github.com/bulletind/khabar.git # or your fork
$ cd khabar
$ DEBUG=* go get && go install && gin -p 8911 -i

Now you should be able to access the below API's on port 8911.

MongoDB config is stored in config/conf.go.

After you make the changes (if you import any new deps), don't forget to run

$ godep save ./...

Usage

$ go get github.com/bulletind/khabar
$ khabar

API

  1. Channels
  2. Add a new channel
```
POST /topic/<notification_ident>/channel/<channel_ident>
```

Request:
```js
{
    org: "",
    user: "",
    ident: ""
}
```
  1. Remove a channel
```
DELETE /topic/<notification_ident>/channel/<channel_ident>
```

Request:
```js
{
  org: "",
  user: "",
  ident: ""
}
```
  1. Get all channels
```
GET /channels
```

Query params:

- `org`: organization id
- `user`: user id

Response:
```js
[
  {
      "_id": "",
      "created_on": 1425545240236,
      "updated_on": 1425545240236,
      "user": "",
      "org": "",
      "app_name": "",
      "data": {
      },
      "ident": ""
  }
]
```
  1. Topics
  2. Add a new topic
```
POST /topic
```

Request:
```js
{
    org: "123",
    user: "",
    ident: "",
    app_name: "myapp"
}
```

- `ident` is requred
- `org` is required
- `app_name` is required
  1. Remove a topic
```
DELETE /topic/<notification_ident>
```

Request:
```js
{
    org: "",
    user: "",
    ident: ""
}
```
  1. Get all topics
```
GET /topics
```

Query params:

- `org`: organization id
- `user`: user id

Response:
```js
[
  {
    "_id": "",
    "created_on": 1425547531188,
    "updated_on": 1425879125700,
    "user": "",
    "org": "",
    "app_name": "",
    "channels": [
      "",
      ""
    ],
    "ident": ""
  }
]
```
  1. Notifications
  2. Get all notifications
```
GET /notifications
```

Query params:

- `user`: user id
- `org`: organization id

Response:
```js
[
  {
    org: "",
    user: "",
    destination_uri: "",
    text: "",
    topic: "",
    destination_uri: "",
    is_read:false,
    created_on: <milliseconds_since_epoch>
   },
   // and so on...
]
```

This can be polled periodically
  1. Mark a single notification as read
```
PUT /notification/:_id
```
  1. Mark all unread notifications as read
```
PUT /notifications
```

- `destination_uri`: Link to relevant entity. #### (i.e action, incident)
- `text`: Notification text
- `topic`: Notification topic
Some general conventions:
  • For all of the above request you must pass atleast one of the org or user or both

  • For all the listings, you get a status code of 200

  • When you create a resource you get a status code of 201

  • When you modify/delete a resource you get a status code of 204

  • Response for creation of an entity

    {
      "body": "[ID of entity created]",
      "message": "Created",
      "status": 201
    }
    
  • Response for modifying/deleting an entity

    {
      "body": "",
      "message": "NoContent",
      "status": 204
    }
    

Todo

  • Verify if the api's listed above are correct and update them.
  • Spin up a nice demo.
  • Ability to use MONGODB_URL from environment variable.
  • Ability to listen on a specified port (--port from command line?) or via PORT environment variable.
  • Deployment and hosting.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Godeps
_workspace/src/code.google.com/p/gcfg
Package gcfg reads "INI-style" text-based configuration files with "name=value" pairs grouped into sections (gcfg files).
Package gcfg reads "INI-style" text-based configuration files with "name=value" pairs grouped into sections (gcfg files).
_workspace/src/code.google.com/p/gcfg/scanner
Package scanner implements a scanner for gcfg configuration text.
Package scanner implements a scanner for gcfg configuration text.
_workspace/src/code.google.com/p/gcfg/token
Package token defines constants representing the lexical tokens of the gcfg configuration syntax and basic operations on tokens (printing, predicates).
Package token defines constants representing the lexical tokens of the gcfg configuration syntax and basic operations on tokens (printing, predicates).
_workspace/src/code.google.com/p/gcfg/types
Package types defines helpers for type conversions.
Package types defines helpers for type conversions.
_workspace/src/github.com/nicksnyder/go-i18n/i18n
Package i18n supports string translations with variable substitution and CLDR pluralization.
Package i18n supports string translations with variable substitution and CLDR pluralization.
_workspace/src/github.com/nicksnyder/go-i18n/i18n/bundle
Package bundle manages translations for multiple languages.
Package bundle manages translations for multiple languages.
_workspace/src/github.com/nicksnyder/go-i18n/i18n/language
Package language defines languages that implement CLDR pluralization.
Package language defines languages that implement CLDR pluralization.
_workspace/src/github.com/nicksnyder/go-i18n/i18n/translation
Package translation defines the interface for a translation.
Package translation defines the interface for a translation.
_workspace/src/gopkg.in/mgo.v2
Package mgo offers a rich MongoDB driver for Go.
Package mgo offers a rich MongoDB driver for Go.
_workspace/src/gopkg.in/mgo.v2/bson
Package bson is an implementation of the BSON specification for Go:
Package bson is an implementation of the BSON specification for Go:
_workspace/src/gopkg.in/mgo.v2/internal/scram
Pacakage scram implements a SCRAM-{SHA-1,etc} client per RFC5802.
Pacakage scram implements a SCRAM-{SHA-1,etc} client per RFC5802.
_workspace/src/gopkg.in/mgo.v2/testserver
WARNING: This package was replaced by mgo.v2/dbtest.
WARNING: This package was replaced by mgo.v2/dbtest.
_workspace/src/gopkg.in/mgo.v2/txn
The txn package implements support for multi-document transactions.
The txn package implements support for multi-document transactions.
dbapi

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL