Code Monkey home page Code Monkey logo

atlan-challenge's Introduction

atlan-challenge

My solution for Atlan Backend Engineering Internship Task

To build the API, run docker-compose up --build inside atlan-challenge directory.

The solution uses worker threads and transactions. Every time a submit request is made, a new worker thread is created to run the query. The query will run in a transaction.

Once the query completes or fails, the query is cancelled and the worker thread dies.

The query runs inside a transaction to keep the update atomic.

  • If user pauses the update, the connection in that new thread is paused.
  • If the user then clicks on resume, that connection can now be resumed.
  • If user cancels, the connection will be destroyed, and then worker thread will be killed. (In such a case, the transaction will anyway be rolled back by the nodejs-mysql module, so partial update isn't an issue here)
  • If the user does not pause, cancel or resume the transaction, and the query successfully completes, it will be committed to the database.

Testing the functionalities

So I have kept a SLEEP(1000) query before and after the UPDATE .. query in the transaction in the getDataForDateRange(..) function, to give time to test the pause, resume and cancel features.

  • These features can be checked by observing that if pause/resume/cancel are pressed- even after more than 20 seconds (enough time for the entire transaction to have run), the logs would not show a successfully committed message.
  • For resume, the transaction would continue, and the changes are successfully committed- unless it was a cancel operation, in which case it would have rolled back and not displayed successful commit message.

Checking the database for changes

After creating the containers, use docker exec -it mysql-db-container mysql -u root -p and enter the password. Then run query SELECT * FROM sakila.customers in the sakila db to check the active field to check if the changes have been reflected in the database.

This was a fun challenge! Hope to hear back from you soon!

atlan-challenge's People

Contributors

ashwinkolhatkar avatar

Stargazers

Roman avatar

Watchers

 avatar

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.