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

[feature] add worker task serialization logic #2989

Conversation

NyaaaWhatsUpDoc
Copy link
Member

Description

Adds necessary serialization / deserialization logic to the different worker message / task types for persisted work queues on startup / shutdown. Also adds a very barebones WorkerTask{} type that will be later filled out + used to store them in the database.

Checklist

Please put an x inside each checkbox to indicate that you've read and followed it: [ ] -> [x]

If this is a documentation change, only the first checkbox must be filled (you can delete the others if you want).

  • I/we have read the GoToSocial contribution guidelines.
  • I/we have discussed the proposed changes already, either in an issue on the repository, or in the Matrix chat.
  • I/we have not leveraged AI to create the proposed changes.
  • I/we have performed a self-review of added code.
  • I/we have written code that is legible and maintainable by others.
  • I/we have commented the added code, particularly in hard-to-understand areas.
  • I/we have made any necessary changes to documentation.
  • I/we have added tests that cover new code.
  • I/we have run tests and they pass locally with the changes.
  • I/we have run go fmt ./... and golangci-lint run.

data: toJSON(map[string]any{
"ap_object_type": ap.ObjectNote,
"ap_activity_type": ap.ActivityCreate,
"gts_model": json.RawMessage(toJSON(&gtsmodel.Status{ID: "69", Content: "hehe"})),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably worth taking a whole status from the testrig for this, with all the funky fields a whole status includes, and ensure that serializes/deserializes as expected. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated to use testrig models here: 2fda9bc

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

though had to switch to using "google/cmp" instead of "testify" for the test comparisons as testify doesn't handle complex types very well like RSA keys :p

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be doubly sure i added a check to ensure account public / private keys are preserved (as those are the most likely to get bodged during json serialization): d4315aa

Copy link
Contributor

@tsmethurst tsmethurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, I've got a few questions about ser/des but that's it :)

@NyaaaWhatsUpDoc NyaaaWhatsUpDoc force-pushed the feature/add-worker-task-serialization-logic branch from c1db6d8 to 7201bae Compare June 20, 2024 09:19
@tsmethurst
Copy link
Contributor

Looks good to me now :) if you're happy then squerge away

@NyaaaWhatsUpDoc NyaaaWhatsUpDoc merged commit 7b1ccbd into superseriousbusiness:main Jun 20, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants