We proceed with the recipe as follows:
- The code for the microservice is straightforward. The code for it is in 10/02/call_scraper_microservice.py and is shown here:
from nameko.rpc import rpcimport sojobs.scraping class ScrapeStackOverflowJobListingsMicroService: name = "stack_overflow_job_listings_scraping_microservice" @rpc def get_job_listing_info(self, job_listing_id): listing = sojobs.scraping.get_job_listing_info(job_listing_id) print(listing) return listingif __name__ == "__main__": print(ScrapeStackOverflowJobListingsMicroService("122517"))
- We have created a class to implement the microservice and given it a single method, get_job_listing_info. This method simply wraps the implementation in the sojobs.scraping module, ...