This commit is contained in:
parent
6ead97eee0
commit
9fec4e81cc
@ -19,14 +19,13 @@ __version__text__ = "1"
|
|||||||
SENTRY_DSN = os.environ.get("SENTRY_DSN")
|
SENTRY_DSN = os.environ.get("SENTRY_DSN")
|
||||||
if SENTRY_DSN:
|
if SENTRY_DSN:
|
||||||
sentry_sdk.init(
|
sentry_sdk.init(
|
||||||
dsn=SENTRY_DSN,
|
dsn = SENTRY_DSN,
|
||||||
integrations=[FlaskIntegration()],
|
integrations = [FlaskIntegration()],
|
||||||
send_default_pii=True,
|
send_default_pii = True,
|
||||||
release=os.environ.get('RELEASE_ID', 'test'),
|
release = os.environ.get('RELEASE_ID', 'test'),
|
||||||
environment=os.environ.get('RELEASEMODE', 'dev')
|
environment = os.environ.get('RELEASEMODE', 'dev')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config['REDIS_URL'] = os.environ['REDIS_URL']
|
app.config['REDIS_URL'] = os.environ['REDIS_URL']
|
||||||
app.config['LOCAL_UUID'] = os.environ['LOCAL_UUID']
|
app.config['LOCAL_UUID'] = os.environ['LOCAL_UUID']
|
||||||
@ -36,7 +35,7 @@ app.config['PRODUCER_TIMEOUT'] = int(os.environ.get('PRODUCER_TIMEOUT', 60))
|
|||||||
redis_client.init_app(app)
|
redis_client.init_app(app)
|
||||||
|
|
||||||
for view in [ConsumersView, LogView, SyncView]:
|
for view in [ConsumersView, LogView, SyncView]:
|
||||||
view.register(app, trailing_slash=False)
|
view.register(app, trailing_slash = False)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(debug=True)
|
app.run(debug = True)
|
||||||
|
@ -10,6 +10,7 @@ def client():
|
|||||||
with current_app.test_client() as client:
|
with current_app.test_client() as client:
|
||||||
yield client
|
yield client
|
||||||
|
|
||||||
|
|
||||||
def test_response_length(client):
|
def test_response_length(client):
|
||||||
r = client.post('/log')
|
r = client.post('/log')
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ from flask_classful import FlaskView
|
|||||||
class ConsumersView(FlaskView):
|
class ConsumersView(FlaskView):
|
||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
|
|
||||||
keys = redis_client.keys('consumer_*')
|
keys = redis_client.keys('consumer_*')
|
||||||
|
|
||||||
list_of_customer_ips = []
|
list_of_customer_ips = []
|
||||||
|
@ -19,7 +19,8 @@ class LogView(FlaskView):
|
|||||||
if not last_known_remote_ip:
|
if not last_known_remote_ip:
|
||||||
current_app.logger.info(f"New producer {remote_uuid} at {remote_ip}")
|
current_app.logger.info(f"New producer {remote_uuid} at {remote_ip}")
|
||||||
elif last_known_remote_ip != remote_ip:
|
elif last_known_remote_ip != remote_ip:
|
||||||
current_app.logger.info(f"IP address of producer {remote_uuid} have changed: {last_known_remote_ip} -> {remote_ip}")
|
current_app.logger.info(
|
||||||
|
f"IP address of producer {remote_uuid} have changed: {last_known_remote_ip} -> {remote_ip}")
|
||||||
|
|
||||||
# update expirity
|
# update expirity
|
||||||
redis_client.set(prod_key, remote_ip.encode('utf-8'))
|
redis_client.set(prod_key, remote_ip.encode('utf-8'))
|
||||||
@ -28,4 +29,4 @@ class LogView(FlaskView):
|
|||||||
# print out message
|
# print out message
|
||||||
current_app.logger.info(f"New message: {request.json['message']}")
|
current_app.logger.info(f"New message: {request.json['message']}")
|
||||||
|
|
||||||
return Response(status=204)
|
return Response(status = 204)
|
||||||
|
Reference in New Issue
Block a user