Skip to content

Commit

Permalink
Merge branch 'release/1.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
smn committed Aug 23, 2016
2 parents 817efbb + aead96c commit 5445216
Show file tree
Hide file tree
Showing 16 changed files with 2,863 additions and 311 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -3,3 +3,5 @@
.coverage
_trial_temp/
/docs/_build
htmlcov/
.cache/
23 changes: 16 additions & 7 deletions .travis.yml
@@ -1,22 +1,31 @@
language: python
python:
- "2.7"
- "pypy"
matrix:
include:
- python: "pypy"
env: PYPY_VERSION="4.0.1" NO_COVERAGE=1
cache:
directories:
- $HOME/.cache/pip
- $HOME/downloads

before_install:
# If necessary, set up an appropriate version of pypy.
- if [ ! -z "$PYPY_VERSION" ]; then source setup-pypy-travis.sh; fi
- if [ ! -z "$PYPY_VERSION" ]; then python --version 2>&1 | fgrep "PyPy $PYPY_VERSION"; fi
install:
- pip install twine
- pip install coveralls
- pip install --upgrade pip
- pip install flake8
- pip install -r requirements-dev.txt
- pip install -e .
- pip install -r requirements-dev.txt
- pip install coveralls
- pip install twine
script:
- flake8 consular
- py.test consular --cov consular
- if [ -z "$NO_COVERAGE" ]; then COVERAGE_OPT="--cov consular"; else COVERAGE_OPT=""; fi
- py.test consular $COVERAGE_OPT
after_success:
- coveralls
- if [ -z "$NO_COVERAGE" ]; then coveralls; fi
deploy:
provider: pypi
user: smn
Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
1.0.2
1.3.0
30 changes: 13 additions & 17 deletions consular/cli.py
@@ -1,7 +1,7 @@
import click
import sys

from urllib import urlencode
from uritools import uricompose


@click.command()
Expand All @@ -16,9 +16,10 @@
@click.option('--marathon', default='http://localhost:8080',
help='The Marathon HTTP API')
@click.option('--registration-id',
help=('Auto register for Marathon event callbacks with the '
'registration-id. Must be unique for each consular '
'process.'), type=str)
help=('Name used to register for event callbacks in Marathon as '
'well as to register services in Consul. Must be unique '
'for each consular process.'),
type=str, default='consular')
@click.option('--sync-interval',
help=('Automatically sync the apps in Marathon with what\'s '
'in Consul every _n_ seconds. Defaults to 0 (disabled).'),
Expand Down Expand Up @@ -53,27 +54,22 @@ def main(scheme, host, port,
sync_interval, purge, logfile, debug, timeout,
fallback, fallback_timeout): # pragma: no cover
from consular.main import Consular
from twisted.internet.task import LoopingCall
from twisted.internet import reactor
from twisted.python import log

log.startLogging(logfile)

consular = Consular(consul, marathon, fallback)
consular.debug = debug
consular.timeout = timeout
consular = Consular(consul, marathon, fallback, registration_id)
consular.set_debug(debug)
consular.set_timeout(timeout)
consular.fallback_timeout = fallback_timeout
if registration_id:
events_url = "%s://%s:%s/events?%s" % (
scheme, host, port,
urlencode({
'registration': registration_id,
}))
consular.register_marathon_event_callback(events_url)
events_url = uricompose(
scheme=scheme, host=host, port=port, path='/events',
query={'registration': registration_id})
consular.register_marathon_event_callback(events_url)

if sync_interval > 0:
lc = LoopingCall(consular.sync_apps, purge)
lc.start(sync_interval, now=True)
consular.schedule_sync(sync_interval, purge)

consular.run(host, port)
reactor.run()

0 comments on commit 5445216

Please sign in to comment.