GithubHelp home page GithubHelp logo

go_test's Introduction

Task challange

You own a coffee shop. You procure coffee beans from a number of suppliers and have them delivered directly to you. You source 3 types of coffee beans: Arabica, Robusta and Liberica. Each supplier supplies one or more types of beans. Drivers work for a carrier, and each carrier can haul one or more types of beans.

Write a SQL query that produces the invalid deliveries. (Invalid deliveries are deliveries that a carrier cannot perform due to carrier bean constraints)

Write a simple Golang server that has an endpoint that will return the results.

You will also need to provide the manifests for deploying the server onto a Kubernetes cluster. (e.g. deployment, service, ingress)

Requirements

You will need to deploy your project using Docker/Kubernetes

Bonus

  • Use gRPC for the server and provide a postman endpoint. Please provide the proto files.
  • Given that each delivery contains a random bean from the supplier's stock, what is the probability that the delivery is valid. Write an endpoint that will return this result.

Task completion status

1. I have written a SQL query that produces the invalid deliveries, here it is

WITH all_compination AS (
		SELECT suppliers.id AS supplier_id,
			   drivers.id   AS driver_id
		FROM drivers
				 CROSS JOIN suppliers),
		 valid_delivery AS (
			 SELECT DISTINCT suppliers.id AS supplier_id,
							 drivers.id   AS driver_id
			 FROM bean_types
					  LEFT JOIN carrier_bean_types ON bean_types.id = carrier_bean_types.bean_type_id
					  LEFT JOIN carriers ON carriers.id = carrier_bean_types.carrier_id
					  LEFT JOIN drivers ON drivers.carrier_id = carriers.id
					  LEFT JOIN supplier_bean_types ON supplier_bean_types.bean_type_id = carrier_bean_types.bean_type_id
					  LEFT JOIN suppliers ON suppliers.id = supplier_bean_types.supplier_id AND drivers.id IS NOT NULL
		 )
	SELECT all_compination.*
	FROM all_compination
			 LEFT JOIN valid_delivery ON valid_delivery.supplier_id = all_compination.supplier_id AND
										 valid_delivery.driver_id = all_compination.driver_id
	WHERE valid_delivery.supplier_id IS NULL
	  AND valid_delivery.driver_id IS NULL

2. I have written a Golang gRPC server with REST proxies that you can build and deploy running the below commands

Dependencies

Building

Strating minikube

start minikube

Switch to Docker daemon inside Minikube VM:

eval $(minikube docker-env)

Build images and deploy to Kubernetes cluster:

./build.sh

Try it out.

minikube service api-service --url
curl <output_url_from_previous_command>/deliveries/invalid_combination

Example

curl --request GET 'http://127.0.0.1:51650/deliveries/invalid_combination'

3. I have written the manifests for deploying the server onto a Kubernetes cluster that can be found below

4. I have used gRPC for the server. Please find the postman and protofiles given below

  • Sample Curl
curl <output_url_from_previous_command>/deliveries/invalid_combination

Example

curl --request GET 'http://127.0.0.1:51650/deliveries/invalid_combination'
  • Proto files can be found here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.