Thisisthecodeusedinthisseriesofarticles:
https://medium.com/p/building-microservices-with-python-part-i-5240a8dcc2fbhttps://medium.com/@ssola/building-microservices-with-python-part-2-9f951199094a#.z48wq941ghttps://medium.com/@ssola/building-microservices-with-python-part-3-a556a4c4bc00#.yn4p8rstpThisisabasicapproachofbuildingaMicroserviceontopofFlask,withsomeusefulpackageslike:
FlaskFlask-InjectorConnexionRequirementsWearegoingtobuildamicroservicetoindexroomsinformationcomingfromanotherservice(crawler).ThisservicewillberesponsibleforindexingtheinformationintoElasticsearch.
Theindexingwillbeaprocessof:
ValidateandsanitizethedataGetsomemetadatafromtheroominformationlikegeolocalizationUploadthegivenimagesURLtoAmazonS3SendaneventtoRabbitMQeverytimeanewroomhasbeenindexedserializingthepayloadwithAvro.Endpoints:
MethodURIDescriptionStatusPOST/roomitwillreceivetheroompayload,anditwillproceedtoindexitDevelopmentPATCH/room/{id}thisPATCHmethodwillallowustomakechangesontheindexeditemNotstartedDELETE/room/{id}thismethodwillremovetheroomfromtheindexNotstartedGET/room/{id}thismethodwillreturntheroomdataforagivenroomidNotstartedGET/health-checkThisendpointretunsthestateoftheserviceNotstartedRunningtheenvironmentYouneedtohaveDockerinstalledinyourmachine,afterthat,justrunthiscommanddocker-composebuild&&docker-composeup-d.
评论