Giter VIP home page Giter VIP logo

worker-process-service-challenge's Introduction

worker-process-service-challenge

This is a prototype implementation of a service that allows running arbitrary processes and a client that can interface with that service remotely over gRPC.

The design document can be found here.

Coding Style

This project roughly follows the somewhat old Rust Style Guidelines by default and the formatting defaults of rustfmt. rustfmt defaults take place over style guidelines should they conflict due to it being newer but is not provided in a written book form.

The project also enforces automatic linting with clippy and will fail on any warning.

CI is configured to fail if the code is not properly formatted or any lints trigger.

Usernames and Identifiers

In a production grade product this should probably rely on something other than usernames for unique user identification. You would probably have some sort of service that associates usernames with UUIDs and that can be used to refer to users internally instead. For simplicity this prototype just sticks with usernames.

Errors

In a production grade product, errors would ideally be handled by handwriting enums and serializing that to error codes over gRPC. Due to time and code size I've opted to simply use human-readable text errors instead.

Certificates and Keys

For the purpose of demonstration, I've included all certificates and keys for the client, server and their CAs as hardcoded files in the data folder.

Tests

A handful of tests are available and are all implemented in the client package. To run them, simply enter the root repository directory and execute cargo test. The test code itself is located in the client/src/tests directory. Current tests cover TLS, authorization and basic usage.

Usage

First, an instance of the server itself needs to be running. This is as simple as compiling the server binary and running it without any arguments. If everything works as intended you should see something similar to this in your console. Please note that all child processes are run with the user and permissions as the user this service is started under.

serving gRPC endpoint at 0.0.0.0:7005

You're then ready to connect to it with the client. The client has a few base parameters that will need to be met for all subcommands and then each subcommand has it's own set of required parameters. The CLI itself has some decent documentation accessible via the --help parameter which may follow the main command or any subcommand.

Some examples are provided below.

Spawning a job

./client --endpoint https://localhost:7005 --username acrimon spawn --program-path /usr/bin/echo --args hi,man --envs TESTENV=ENVVALUE --working-directory /sys

Stopping a job

./client --endpoint https://localhost:7005 --username acrimon stop --uuid <uuid>

Fetch the status for a job

./client --endpoint https://localhost:7005 --username acrimon status --uuid <uuid>

Stream all past and future output events from a job

./client --endpoint https://localhost:7005 --username acrimon stream-log --stream-type <stream-type> --past-events --uuid <uuid>

Valid values for stream-type are

  • raw
  • stdout
  • stderr

worker-process-service-challenge's People

Contributors

xacrimon avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

icodein

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.