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

chore(refactor): add ingress event type and refactor timeline #2719

Merged
merged 2 commits into from
Sep 18, 2024

Conversation

wesbillman
Copy link
Collaborator

This is mostly the refactor and setting up for the new ingress events. I'm pushing this up first because it will get quite large once I add ingress and a bit more refactoring. :)

Actual ingress events will come next.

@wesbillman wesbillman requested review from a team, stuartwdouglas and deniseli and removed request for a team September 18, 2024 17:43
This was referenced Sep 18, 2024
@wesbillman wesbillman force-pushed the add-ingress-event-type-and-refactor branch 2 times, most recently from e92ecb3 to a1ff7cc Compare September 18, 2024 17:55
RequestKey model.RequestKey
}

// The internal JSON payload of an ingress event.
Copy link
Contributor

Choose a reason for hiding this comment

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

nittiest of nits: some of the json structs have comments and others don't. Did you want to remove the extant comments or add a comment wherever they're missing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Haha I'm just random 😂 I'll make sure they all have them 👍

Stack optional.Option[string] `json:"stack,omitempty"`
}

type Call struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need both Call and CallEvent?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The idea here is the Call is what's used as the external API to insert calls into the db. And CallEvents are what are returned from the query. Maybe there's a better name for this 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

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

Makes sense but I would embed Call into CallEvent so you're not duplicating fields.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Awesome! Will do in the next PR. I might have some questions about how to do this correctly :)

Comment on lines +75 to +85
(CASE
WHEN sqlc.narg('parent_request_key')::TEXT IS NULL THEN NULL
ELSE (SELECT id FROM requests ir WHERE ir.key = sqlc.narg('parent_request_key')::TEXT)
END),
sqlc.arg('time_stamp')::TIMESTAMPTZ,
'ingress',
sqlc.narg('source')::TEXT,
sqlc.narg('destination_module')::TEXT,
sqlc.arg('ingress_type')::TEXT,
sqlc.narg('http_method')::TEXT,
sqlc.arg('payload')
Copy link
Contributor

Choose a reason for hiding this comment

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

How did you want to handle the rest of these args, since only deployment_key and request_key are populated in events_ingress.go?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah you can ignore this for now. I'm going to actually populate the ingress event right after this PR merges, but I need to think through the exact fields a bit and didn't want to keep adding to this mega PR

}
// TimelineEvent types.
//
//sumtype:decl
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this do anything outside of a module? :o

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's for the sumtype tool in go to make this interface as a sumtype.

Copy link
Contributor

Choose a reason for hiding this comment

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

ahhhh got it

if err := d.encryption.DecryptJSON(&row.Payload, &jsonPayload); err != nil {
return nil, fmt.Errorf("failed to decrypt call event: %w", err)
if err := s.encryption.DecryptJSON(&row.Payload, &jsonPayload); err != nil {
return nil, fmt.Errorf("failed to decrypt deployment created event: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

nice catch!

@wesbillman wesbillman force-pushed the add-ingress-event-type-and-refactor branch from 2d05edb to cd4b33f Compare September 18, 2024 18:30
Stack optional.Option[string] `json:"stack,omitempty"`
}

type Call struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Makes sense but I would embed Call into CallEvent so you're not duplicating fields.

Error optional.Option[string] `json:"error,omitempty"`
}

type Log struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same thing here, and probably with all the events potentially? I'd embed the struct.

@wesbillman wesbillman merged commit c94d3a9 into main Sep 18, 2024
91 checks passed
@wesbillman wesbillman deleted the add-ingress-event-type-and-refactor branch September 18, 2024 19:06
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.

3 participants