SextantDocs
v2.4latest
v2.4latestv1.9legacy

Switching keeps you on the same page when it exists in the other version.

On this page

QuickstartNew

Start a server, register a handler, create a job and watch it run, in about five minutes.

Updated Getting started Version v2.4

By the end of this page a job will have moved from queued to succeeded on your machine. You need the installed binary and a running server.

  1. Describe a handler

    A handler is a name Sextant can map to code. The simplest one is a shell command: Sextant sends the job payload on standard input and treats exit code 0 as success.

    sextant.tomlTOML
    [server]
    listen = "127.0.0.1:7420"
    
    [store]
    driver = "sqlite"
    dsn = "file:sextant.db"
    
    [handlers.hello]
    exec = ["sh", "-c", "echo hello $(cat | jq -r .name)"]
    timeout = "30s"
    
    [queues.default]
    concurrency = 10
  2. Start a worker

    In a second terminal, with SEXTANT_URL and SEXTANT_TOKEN exported:

    Shell
    sextant worker --queues default
  3. Create a job

    CLIShell
    sextant jobs create --queue default --handler hello --payload '{"name":"Ada"}'
    NodeTypeScript
    import { Sextant } from '@sextant/node';
    
    const sextant = new Sextant({ token: process.env.SEXTANT_TOKEN });
    const job = await sextant.jobs.create({
      queue: 'default',
      handler: 'hello',
      payload: { name: 'Ada' },
    });
    console.log(job.id, job.state);
    PythonPython
    import os
    from sextant import Sextant
    
    client = Sextant(token=os.environ["SEXTANT_TOKEN"])
    job = client.jobs.create(queue="default", handler="hello", payload={"name": "Ada"})
    print(job.id, job.state)
    GoGo
    client := sextant.NewClient(os.Getenv("SEXTANT_TOKEN"))
    job, err := client.Jobs.Create(ctx, &sextant.JobCreateParams{
    	Queue:   "default",
    	Handler: "hello",
    	Payload: map[string]any{"name": "Ada"},
    })
  4. Watch it run

    Shell
    $ sextant inspect job_8f3k2m9q
    job_8f3k2m9q  hello  default  succeeded
    attempt 1  worker wrk_a91c7e  41 ms  exit 0
    output     hello Ada

What just happened

  1. The server stored the job as queued.
  2. The worker leased it, ran echo hello Ada and reported exit code 0.
  3. The server marked the job succeeded and kept the attempt record for seven days (see retention).

Where to go next