Skip to content

Commit

Permalink
Merge pull request #75 from giovannicuriel/update-versions
Browse files Browse the repository at this point in the history
Update versions, fixing producer for dojot.tenancy
  • Loading branch information
giovannicuriel committed Mar 13, 2019
2 parents 9f64080 + 093e442 commit d893754
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 29 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ RUN python3 -m venv /usr/src/venv
ENV VIRTUAL_ENV="/usr/src/venv"
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

ADD . /usr/src/app
COPY ./requirements/requirements.txt ./requirements
RUN pip install -r requirements/requirements.txt

FROM python:3.6-alpine

COPY --from=basis /usr/src/venv /usr/src/venv
COPY --from=basis /usr/src/app /usr/src/app
COPY . /usr/src/app

RUN apk update && apk --no-cache add libpq libstdc++

Expand Down
4 changes: 4 additions & 0 deletions auth/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
# Global subject to use when publishing tenancy lifecycle events
kafka_subject = 'dojot.tenancy'


dojot_management_tenant = os.environ.get('DOJOT_MANAGEMENT_TENANT', "dojot-management")
dojot_management_user = os.environ.get('DOJOT_MANAGEMENT_USER', "auth")

# Kafka topic (subject) manager
data_broker_host = os.environ.get("DATA_BROKER_URL", 'http://data-broker')

Expand Down
34 changes: 8 additions & 26 deletions auth/controller/KafkaPublisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import requests
import logging
import json
from conf import kafka_subject, kafka_host, data_broker_host
from conf import kafka_subject, kafka_host, data_broker_host, dojot_management_tenant
from dojot.module import Messenger, Config, Log
import threading
import time
Expand Down Expand Up @@ -32,29 +32,6 @@ def init(cls):

LOGGER.debug("Initializing dojot.module")
config = Config({
"kafka" : {
"producer": {
"client.id": "dojot.auth",
"metadata.broker.list": kafka_host,
"compression.codec": "gzip",
"retry.backoff.ms": 200,
"message.send.max.retries": 10,
"socket.keepalive.enable": True,
"queue.buffering.max.messages": 100000,
"queue.buffering.max.ms": 1000,
"batch.num.messages": 1000000,
"dr_cb": True
},
"consumer": {
"group.id": "dojot.auth",
"metadata.broker.list": kafka_host
}
},
"data_broker" : {
"url": data_broker_host,
"connection_retries": 3,
"timeout_sleep": 5
},
"auth" : {
"url": "http://localhost:5000",
"connection_retries": 3,
Expand All @@ -64,11 +41,16 @@ def init(cls):

LOGGER.debug("Config is: " + json.dumps(config.auth))
cls.messenger = Messenger("dojot.auth", config)
LOGGER.debug(f"Creating tenant {dojot_management_tenant}...")
LOGGER.debug(f"Current tenants are: {cls.messenger.tenants}.")
cls.messenger.process_new_tenant(dojot_management_tenant, json.dumps({"tenant" : dojot_management_tenant}))
LOGGER.debug("... tenant created.")
LOGGER.debug("Creating channel " + kafka_subject)
cls.messenger.create_channel(kafka_subject, "w")
LOGGER.debug("... channel created.")
LOGGER.debug("Initializing messenger")
cls.messenger.init()
LOGGER.debug("... messenger initialized.")
LOGGER.debug("Creating channel " + kafka_subject)
cls.messenger.create_channel(kafka_subject, "w")

def run(self):
self.init()
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ json-logging-py==0.2
flask-redis==0.3.0
marisa_trie==0.7.4
git+https://github.com/dojot/alarm-client-python.git#egg=dojot-alarmlibrary
dojot.module==0.0.1a1
dojot.module==0.0.1a4

0 comments on commit d893754

Please sign in to comment.