Coder Social home page Coder Social logo

allensuvorov / tasker Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 225 KB

Modified Proxy Service. Two micro-services. One - receives tasks, saves to DB, returns statuses. The other - polls new tasks, concurrently runs them, updates statuses.

Go 100.00%
concurrency docker go golang microservices

tasker's Introduction

Tasker - job scheduler

Project Description

The client sends a task to the service to perform an http request to a 3rd-party services. The task is described in json format, the generated task id is returned in response and its execution starts in the background.

Project Architecture

Two microservices. First microservice receives tasks, saves them to DB, returns statuses. Second microservice polls DB to get new tasks, concurrently runs them - makes HTTP requests to 3rd-party services and updates statuses in the DB.

Configuration

Set the postgres Database connection string / Data Source Name (DSN) to the env variable "DATABASE_DSN".

To test/run the app

To run and test the agent (job scheduler):

  • NOTE: agent runs independently. No need to start the server.
  • First, fill up the DB with test data by running this test:
    • path: internal/server/storage/db_test.go
    • test name: "TestTaskStorage_Create30Tasks_RealDB"
  • Run the agent: cmd/agent/agent.go

To run and test the server:

  • To start the server run: cmd/main/main.go
  • For a POST request run this test:
    • path "internal/server/storage/db_test.go"
    • test name: "TestTaskStorage_CreateTask_RealDB"
  • For a GET request run this test:
    • path: internal/server/storage/db_test.go,
    • test name: "TestTaskStorage_GetTaskStatus_RealDB"

tasker's People

Contributors

allensuvorov avatar

Watchers

James Cloos avatar  avatar

tasker's Issues

Problem: polling is not a perfect solution. Find another solution.

"Implemented task polling with timeout. With this approach, we can go to the database without receiving new data, or vice versa, forcing the user to wait an extra 500ms until it's time to go for tasks. At this point, we expected to see work with channels, when, after writing to the database, the request handler is immediately launched."

Which would it be, to keep services decoupled?

  • message queque
  • gRPC
  • other?

Portfolio ready - check list

  • resolve all issues
  • tests
  • describe the functionality and what's implemented (polling etc.)
  • short video - 3-5 minutes

Remove these global variables taskCh & resultCh

Remove these global variables taskCh & resultCh

  • var taskCh = make(chan entity.TaskEntity)
  • var resultCh = make(chan entity.ResultEntity, 5)

Try not to use global vars, they make it harder to write tests.

Mode Domain up to Internal folder

Domain contains items used by both, service and agent. Currently domain folder is in service folder. It should be up in the Internal folder.

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.