Skip to content

Commit

Permalink
additional documentation for mosquito::api classes and methods
Browse files Browse the repository at this point in the history
  • Loading branch information
robacarp committed Jan 2, 2025
1 parent c03b9a0 commit 1bf9901
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/mosquito/api/executor.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
module Mosquito
module Api
# An interface for an executor.
#
# This is used to inspect the state of an executor. For more information about executors, see `Mosquito::Runners::Executor`.
class Executor
getter :instance_id
private getter :metadata
Expand Down
12 changes: 11 additions & 1 deletion src/mosquito/api/job_run.cr
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
module Mosquito::Api
# Represents a job run in Mosquito.
#
# This class is used to inspect a job run stored in the backend.
#
# For more information about a JobRun, see `Mosquito::JobRun`.
class JobRun
# The id of the job run.
getter id : String

def initialize(@id : String)
end

# Does a JobRun with this ID exist in the backend?
def found? : Bool
config.has_key? "type"
end

# Get the parameters the job was enqueued with.
def runtime_parameters : Hash(String, String)
config.reject do |key, _|
["id", "type", "enqueue_time", "retry_count", "started_at", "finished_at"].includes? key
Expand All @@ -28,17 +36,19 @@ module Mosquito::Api
config["type"]
end

# A Time object representing the moment this job was enqueued.
# The moment this job was enqueued.
def enqueue_time : Time
Time.unix_ms config["enqueue_time"].to_i64
end

# The moment this job was started.
def started_at : Time?
if time = config["started_at"]
Time.unix_ms time.to_i64
end
end

# The moment this job was finished.
def finished_at : Time?
if time = config["finished_at"]
Time.unix_ms time.to_i64
Expand Down
4 changes: 3 additions & 1 deletion src/mosquito/api/overseer.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module Mosquito
# A utility for inspecting the state of Mosquito Overseers.
# An interface for inspecting the state of Mosquito Overseers.
#
# For more information about overseers, see `Mosquito::Runners::Overseer`.
class Api::Overseer
# The instance ID of the overseer being inspected.
getter :instance_id
Expand Down

0 comments on commit 1bf9901

Please sign in to comment.