Browse Source

Tweaks

master
Noah Pederson 2 years ago
parent
commit
3383814dd5
6 changed files with 9 additions and 7 deletions
  1. +1
    -1
      connexion_example/Dockerfile
  2. +2
    -3
      connexion_example/app.py
  3. +2
    -1
      connexion_example/requirements.txt
  4. +2
    -0
      docker-compose.yaml
  5. +1
    -1
      nameko_example/logger_service.py
  6. +1
    -1
      nameko_example/pet_service.py

+ 1
- 1
connexion_example/Dockerfile View File

@ -10,4 +10,4 @@ RUN pip install -r requirements.txt
COPY . .
ENTRYPOINT python app.py
ENTRYPOINT ["gunicorn", "app", "-w", "4", "--bind", "0.0.0.0:8080", "--reload"]

+ 2
- 3
connexion_example/app.py View File

@ -3,7 +3,7 @@ import connexion
import datetime
import logging
import os
import atexit
from connexion import NoContent
from nameko.standalone.rpc import ClusterRpcProxy
@ -15,7 +15,6 @@ config = {
'AMQP_URI': os.environ["AMQP_URI"] #"pyamqp://guest:guest@localhost"
}
def get_pets(limit, animal_type=None):
with ClusterRpcProxy(config) as cluster_rpc:
pets = cluster_rpc.pet_service.get_pets(limit, animal_type=animal_type)
@ -52,4 +51,4 @@ app.add_api('swagger.yaml')
application = app.app
if __name__ == '__main__':
app.run(port=8080)
app.run(port=8080, threaded=False)

+ 2
- 1
connexion_example/requirements.txt View File

@ -8,6 +8,7 @@ dnspython==1.16.0
eventlet==0.24.1
Flask==1.0.2
greenlet==0.4.15
gunicorn==19.9.0
idna==2.8
importlib-metadata==0.8
inflection==0.3.1
@ -31,4 +32,4 @@ urllib3==1.24.1
vine==1.2.0
Werkzeug==0.14.1
wrapt==1.11.1
zipp==0.3.3
zipp==0.3.3

+ 2
- 0
docker-compose.yaml View File

@ -7,6 +7,8 @@ services:
expose:
- 5672
- 15672
ports:
- "15672:15672"
restart: always
networks:
- nameko


+ 1
- 1
nameko_example/logger_service.py View File

@ -1,5 +1,5 @@
from nameko.events import event_handler, SINGLETON
import logging
class LoggerService:
name = "system_logger"


+ 1
- 1
nameko_example/pet_service.py View File

@ -36,7 +36,7 @@ class PetService:
@rpc
def get_pets(self, limit, animal_type=None):
self.dispatch("log", f"Recevied request to list all pets with anime_type {animal_type}")
self.dispatch("log", f"Recevied request to list all pets with animal_type {animal_type}")
return [pet for pet in pets.values() if not animal_type or pet['animal_type'] == animal_type][:limit]
@rpc


Loading…
Cancel
Save