Skip to content

Commit

Permalink
Merge 9102372 into 02cd95c
Browse files Browse the repository at this point in the history
  • Loading branch information
briehl committed Oct 26, 2018
2 parents 02cd95c + 9102372 commit c7ce1f0
Show file tree
Hide file tree
Showing 58 changed files with 1,859 additions and 155 deletions.
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[run]
omit = test/*
source = feeds
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ python:
- 3.6
services:
- docker
# env:
# global:

before_install:
- sudo apt-get -qq update
Expand All @@ -17,4 +15,7 @@ install:
- pip install -r dev-requirements.txt

script:
- make test
- make test

after_script:
- coveralls
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
install:
pip install -r requirements.txt

build-docs:
docs:
-rm -r docs
-rm -r docsource/internal_apis
mkdir -p docs
sphinx-apidoc --separate -o docsource/internal_apis src
sphinx-apidoc --separate -o docsource/internal_apis feeds

test:
# flake8 feeds
pytest --verbose test --cov feeds
flake8 feeds
pytest --verbose test --cov --cov-report html feeds -s

start:
gunicorn --worker-class gevent --timeout 300 --workers 10 --bind :5000 feeds.server:app
gunicorn --worker-class gevent --timeout 300 --workers 17 --bind :5000 feeds.server:app

.PHONY: test
.PHONY: test docs
53 changes: 53 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
### Notification
* handle plain string or structured note context
* service-dependent
* subclass, or otherwise mark context for each service
* avoid subclassing, so we don't need to modify feeds whenever a new service is added

### NotificationFeed
* combine with global feed for maintenance, etc.

### NotificatonManager
* handle fanouts in a more consistent way

### TimelineStorage
* abstract caching
* filters on
* seen
* service
* level
* add remove notification

### ActivityStorage
* caching to avoid lookups
* expire activities after configured time

### Storage
* prototype with MongoDB adapter

### Build & Deployment
* build Dockerfile
* build DockerCompose file
* Dockerize
* Sphinx docs
* make service token and encrypt

### Server
* add params to GET notifications endpoint

### Test Interface
* make one.
* maybe jump straight into KBase-UI module.

### Actor
* validate actor properly
* include groups as an actor

### Object
* validate object of notification where appropriate
* context dependent

### Docs
* Do so, in general
* annotate deploy.cfg.example

6 changes: 0 additions & 6 deletions deploy.cfg.example

This file was deleted.

35 changes: 35 additions & 0 deletions deployment/conf/.templates/deploy.cfg.templ
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[feeds]
# DB info
# db-engine - allowed values = redis, mongodb. Others will raise an error on startup.
db-engine = {{ default .Env.db_engine "mongodb" }}

# db-name - name of the database to use. default = "feeds".
db-name = {{ default .Env.db_name "feeds" }}

# Other db info. The usual - host, port, user, and password. You know the drill.
db-host = {{ default .Env.db_host "ci-mongo" }}
db-port = {{ default .Env.db_port "27017" }}
db-user = {{ default .Env.db_user "feedsserv" }}
db-pw = {{ default .Env.db_pw "fake_password" }}

# admins are allowed to use their auth tokens to create global notifications.
# examples would be notices about KBase downtime or events.
admins = wjriehl,scanon,kkeller,drakemm

# fake user name for the global feed. Should be something that's not a valid
# user name.
global-feed = {{ default .Env.global_feed "_global_" }}
# Default lifetime for each notification in days. Notes older than this won't be
# returned without explicitly looking them up by either their id or external key
# (when given).
lifespan = {{ default .Env.lifespan "30" }}

# In debug mode, auth is mostly ignored.
# Useful for testing, etc.
# SET TO FALSE IN PRODUCTION!
debug = False

auth-url = {{ default .Env.auth_url "https://ci.kbase.us/services/auth" }}
workspace-url = {{ default .Env.workspace_url "https://ci.kbase.us/services/ws" }}
groups-url = {{ default .Env.groups_url "https://ci.kbase.us/services/groups" }}
36 changes: 36 additions & 0 deletions deployment/deploy.cfg.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[feeds]
# DB info
# db-engine - allowed values = redis, mongodb. Others will raise an error on startup.
db-engine=mongodb

# db-name - name of the database to use. default = "feeds".
db-name=feeds

# Other db info. The usual - host, port, user, and password. You know the drill.
db-host=localhost
db-port=6379
db-user=
db-pw=

# Service urls
auth-url=https://ci.kbase.us/services/auth
workspace-url=https://ci.kbase.us/services/ws
groups-url=https://ci.kbase.us/services/groups

# admins are allowed to use their auth tokens to create global notifications.
# examples would be notices about KBase downtime or events.
admins=wjriehl,scanon,kkeller,mmdrake

# fake user name for the global feed. Should be something that's not a valid
# user name.
global-feed=_global_

# Default lifetime for each notification in days. Notes older than this won't be
# returned without explicitly looking them up by either their id or external key
# (when given).
lifespan=30

# In debug mode, auth is effectively ignored.
# Useful for testing, etc.
# SET TO FALSE IN PRODUCTION!
debug=False
28 changes: 28 additions & 0 deletions deployment/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
services:
feeds:
ports:
- "5000":"5000"
environment:
- db-engine=mongodb
- db-name=feeds
- db-host=localhost
- db-port=27017
- auth-url=https://ci.kbase.us/services/auth
- workspace-url=https://ci.kbase.us/services/ws
- groups-url=https://ci.kbase.us/services/groups
- AUTH_TOKEN=fake_token
command:
- "-wait"
- "tcp://ci-mongo:27017"
- "-timeout"
- "-template"
- "/kb/module/deployment/conf/.templates/deploy.cfg.templ:/kb/module/deploy.cfg"
- "make start"
depends_on: ["ci-mongo"]

ci-mongo:
image: mongo:2
command:
- "--smallfiles"
ports:
- "27017:27017"
Empty file added deployment/push2dockerhub.sh
Empty file.
4 changes: 3 additions & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
coverage==4.5.1
pytest-cov==2.6.0
flake8==3.5.0
pytest==3.8.2
pytest==3.8.2
coveralls==1.5.1
requests-mock==1.5.2
7 changes: 6 additions & 1 deletion feeds/activity/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from abc import abstractmethod


class BaseActivity(object):
"""
Common parent class for Activity and Notification.
Activity will be done later. But a Notification is an Activity.
"""
pass
@abstractmethod
def to_dict(self):
pass
Loading

0 comments on commit c7ce1f0

Please sign in to comment.