summaryrefslogtreecommitdiff
path: root/Omni/Agent/Core.hs
blob: 88f7237ec6b0193d816d8ed5f7223f7466246345 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE NoImplicitPrelude #-}

module Omni.Agent.Core where

import Alpha
import Data.Aeson (FromJSON, ToJSON)

-- | Status of a worker agent
data WorkerStatus
  = Idle
  | Syncing
  | -- | Task ID
    Working Text
  | -- | Task ID
    Submitting Text
  | -- | Error message
    Error Text
  deriving (Show, Eq, Generic)

instance ToJSON WorkerStatus

instance FromJSON WorkerStatus

-- | Representation of a worker agent
data Worker = Worker
  { workerName :: Text,
    workerPid :: Maybe Int,
    workerStatus :: WorkerStatus,
    workerPath :: FilePath,
    workerQuiet :: Bool -- Disable ANSI status bar (for loop mode)
  }
  deriving (Show, Eq, Generic)

instance ToJSON Worker

instance FromJSON Worker