Giter Site home page Giter Site logo

taskmaster's Introduction

classDiagram
direction LR
namespace common {
    class Server {
        -UnixListener socket
        -Vec~epoll_event~ events
        -RawFd pollfd
        HashMap~Key, UnixStream~ clients

        -listen()
        +accept()
        +recv()
        +send()

    }
    class Request {
        +Cmd command
        +Vec~string~ arguments
        +Key client_key
        +validate()
    }
    class Response {
        +String message
        +finished bool
        +as_bytes()
    }
    class Cmd {
        <<Enumeration>>
        ATTACH
        UNATTACH
        LOG
        HEAD
        STATUS
    }
    class CmdHandler {
        <<Interface>>
        handle(request)
        attach(request)
        unattach(request)
        log(request)
        head(request)
        status(request)
        other(request)
    }
    class ClientState {
        <<Enumeration>>
        Attached
        Unattached
    }
}

%% Request "*" --* "1" BackEndClient
%% Server "1" --o "1" TaskMaster
%% Server "1" --o "1" Client
%% CmdHandler ..|> BackEnd


namespace daemon {
    class TaskMaster {
        -Server server
        -BackEnd backend
        -HashMap~Key, BackEndClient~ clients
        -Status status

        +build(config)
        +reload()
        +accept()
        +receive(Key)
        +respond(Key)
    }

    class Status {
        <<Enumeration>>
        Starting
        Reloading
        Active
    }

    class BackEndClient {
        +ClientState state
        +VecDeque~Request~ requests
    }

    class BackEnd {
        +TaskMasterConfig config
        +HashMap~String, Program~ programs
        +startProcesses()
        +updateProcesses()
        +processRequest() Response
    }

    class Program {
        +ProgramConfig config
        +Vec~Process~ processes

        +build()
        +update()
    }

    class Process {
        +Result~Child, Error~ child
        +ProcessStatus status
    }

    class ProcessStatus {
        <<Enumeration>>
        Starting,
        FailedToStart,
        Active,
        GracefulExit~u32~,
        Killed~Signal~,
        FailedExit~u32~,
    }

    class TaskMasterConfig {
        <<yaml representation>>
        +HashMap~String, ProgramConfig~
    }
}

Status --o TaskMaster
BackEnd "1" --* "1" TaskMaster
BackEndClient "*" --* "1" TaskMaster
Program "*" --o "1" BackEnd
Process "1" --o "1" ProcessStatus
Process "*" --o "1" Program
TaskMasterConfig "1" --o "1" BackEnd


namespace ctl {
    class Client {
        -Server server
        -VecDeque~string~ queries
        -ClientState state
    }
}

namespace log {
    class Logging {
        <<Macros>>
        -int loglevel
        +debug()
        +info()
        +warning()
        +error()
    }
}

Loading

taskmaster's People

Contributors

vln37 avatar paulo-santana avatar

Watchers

 avatar

taskmaster's Issues

front end help command

Appropriate help text for error. Ex:

  • InvalidCommand -> help.commads()
  • InvalidArgument -> help.feature(command)

Integration with rustdocs??

Unattach support

Zero supporting structure to unattach from program, need to rework the code and supporting structs

starting data structures

We need the parsed config information to be represented into relevant data structures for our program to work.

Connect daemon with ctl

We need a bidirectional UNIX socket between front and backend of our supervisor.

We're interested in the infrastructure so dumping the content should be enough for now

Logging System Prototype

The logging emit function will have the following prototype:

fn emit(msg: &str, program: &Program)

It can be reasonably hard coded.

basic format should be [$datetime] $log_level $program $msg

Might be necessary to thread the monitoring feature later? Plan accordingly

minimal interactive shell

User should be able to prompt an interactive shell with at least one command or check the status of a program

Mid attachment request logic

When the client's request is attached it should respond only with the attached program's output

Unsure if bool request finished status is enough to support this behaviour

establish communcation protocol

Define the standard for communication between front-back end.

Statuses?
Headers?
Content?

Common interfaces should be in the appropriate crates.

minimal config parsing

Parse a YAML file into the necessary requirements for our supervisor to work

These include:

  • The command to use to launch the program
  • The number of processes to start and keep running
  • Whether to start this program at launch or not
  • Whether the program should be restarted always, never, or on unexpected exits only
  • Which return codes represent an "expected" exit status
  • How long the program should be running after it’s started for it to be considered "successfully started"
  • How many times a restart should be attempted before aborting
  • Which signal should be used to stop (i.e. exit gracefully) the program
  • How long to wait after a graceful stop before killing the program
  • Options to discard the program’s stdout/stderr or to redirect them to files
  • Environment variables to set before launching the program
  • A working directory to set before launching the program
  • An umask to set before launching the program

start at least one program in background

We need at least a single program running in the background and being monitored by our supervisor.

It can be hardcoded but should at least use the existing interfaces.

read_to_string returns 0

When connection is dropped by client read_to_string returns 0 independently and errno is not updated. Need to investigate how to recover the correct error.

adapt server for attachment

Establish how the front end requests an attachment to a process and synchronize front and backend to know they are operating on this new mode.

EPOLLIN and EPOLLOUT will need to be handled differently by both ends in that case.

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.