Skip to content

saiashirwad/mysqueue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Very much a work in progress.

import { z } from 'zod'
import { Duration, Effect } from 'effect'
import { createQueue, QueueContext, startWorkers } from "@texoport/mysqueue";
import * as Schema from '@effect/schema'

const something = Effect.gen(function* () {
  const ctx = yield* QueueContext;
  console.log(ctx.job)
})


const testQueue = createQueue(
  "test",
  Schema.Struct({
    name: Schema.String
  }),
  (payload) =>
    Effect.gen(function* () {
      const ctx = yield* QueueContext
      console.log("Do stuff")
      yield* something
      if (payload.name === "texoport") {
        return yield* ctx.retry(Duration.seconds(2))
      }
      console.log(payload.name, " complete");
    }),
);

await startWorkers([testQueue]);

0% chance of working lmao (I just copy pasted the code from a different project)

TODO

  • use SELECT ... FOR UPDATE SKIP LOCKED
  • Remove dependency on date-fns (effect/DateTime should be able to handle it)
  • Remove dependency on kysely (switch to @effect/sql-mysql2)
  • Set up migrations function that runs whenever the queue starts
  • Remove dependency on Zod and support any validator

About

A mysql+effect job queue

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published