Handling Database Transactions and Job Dispatching in Effect TypeScript

hi, i have something like this, basically program is using database transaction, and it creates recrods in the db and dispatch the job (that job fetches the record from the db which was created, since payload is large around 100-200kb so i cannot store in redis, that why i need to fetch from db) since all the records are created in a single transaction so, the job handler does not get any record in the db since transaction has not been comitted yet.

how can i dispatch job after program is done (dispatch only on success)

function doSomething(...args: any[]) {
  return Effect.gen(function* () {
    const didSomething = yield* something()
    // did something more

    const job = yield* SomeJob.dispatch(...some_args)

    // did something more
  })
}

const program = Effect.gen(function* () {
  const doSomething_1 = yield* doSomething(1)
  const doSomething_2 = yield* doSomething(2)
  const doSomething_3 = yield* doSomething(3)

  const queueJob_1 = yield* queueJob(doSomething_1, doSomething_2, doSomething_3)

  const doSomething_4 = yield* doSomething(4)
  return something
})
Was this page helpful?