Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use river + newman, remove marionette + posthog #87

Merged
merged 2 commits into from
Sep 29, 2024

Conversation

golanglemonade
Copy link
Member

@golanglemonade golanglemonade commented Sep 25, 2024

Job Queue

  • Updates all async jobs to use use the river client instead of marionette (e.g. emails)
  • Adds the Job client to the ent client directly using ent templating, this allows the Job client to be accessed via both the mutation e.g. m.Job in an ent hook as well via the db client, e.g. h.DBClient.Job (See the ent/templates for added templates that allow for this generation over using the entc.Dependency
  • Adds riverboat to the docker compose setup, migrations for the jobs db will be run as part of that container being brought up. By default this will run in dev-mode (controlled by riverboat config settings) and things like emails will not actually be sent, but saved to the container volume, you can see them in logs as well by running
    docker logs riverboat
    
  ...
  2024-09-28T20:26:01Z INF email.go:65 sending email app=riverboat go_version=go1.23.1 pid=1 subject="Join Your Teammate Matt on Openlane!" to=["[email protected]"]
  2024-09-28T20:26:01Z DBG email.go:71 running in dev mode app=riverboat directory=fixtures/email go_version=go1.23.1 pid=1
  ...
  • Adds riverboat to the aio image
  • Adds the job db connection to the ready checks:
{
  "status": {
    "db_primary": "OK",
    "fga": "OK",
    "job_queue": "OK",
    "redis": "OK"
  }
}
  • Uses rivertest to confirm jobs are added during unit tests

Other Changes

  • Adds the Modifier feature in order to have access to modify the queries and mutations before the are exectuted
  • Adds the DB directly to the client so you can write queries directly:
       rows, err := h.DBClient.DB().Query("SELECT last_name FROM users WHERE first_name = $1 LIMIT 1", "matt")
       if err != nil {
     	  return err
       }
       defer rows.Close()
    
       for rows.Next() {
     	  var out string
     	  rows.Scan(&out)
    
     	  log.Info().Msg(out)
       }
    Note that this will bypass all hooks/interceptors so caution should be used that this do not have auth protection/filtering.
    This was chosen over using the Exec Query feature because that is not compatible with our double wrapped debug driver + encache driver, which is the default we are using right now.
  • Adds support for the pgx driver, this is the preferred driver for riverqueue, and works with ent so the config I have setup (and now in the example config) uses pgx instead of postgres as the driver config for ent
  • Removes kafka from the task run-dev, but leaving the compose and task commands for now
  • Removes the dbx client, because riverboat will now handle the dedicated database creation via a job, there is not currently a requirement for this client. If/when we want to use a dedicated database, we should add the DBx client to the new DBClient instead.
  • Removes posthog analytics
  • Modified all the hooks to consistently using m vs. sometimes m and sometimes mutation in the function signature (the interceptors all already consistently used q for the query.

Signed-off-by: Sarah Funkhouser <[email protected]>
@golanglemonade golanglemonade marked this pull request as ready for review September 28, 2024 21:46
Copy link

sonarcloud bot commented Sep 28, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
15.4% Coverage on New Code (required ≥ 20%)

See analysis details on SonarCloud

@golanglemonade golanglemonade enabled auto-merge (squash) September 29, 2024 01:52
@golanglemonade golanglemonade merged commit 4eadf82 into main Sep 29, 2024
17 of 18 checks passed
@golanglemonade golanglemonade deleted the feat-river branch September 29, 2024 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants