-
Notifications
You must be signed in to change notification settings - Fork 75
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
🌱 add sequence id for status update event #308
🌱 add sequence id for status update event #308
Conversation
/assign @qiujian16 |
/assign @morvencao |
@@ -29,12 +30,14 @@ const ( | |||
|
|||
// ManifestCodec is a codec to encode/decode a ManifestWork/cloudevent with ManifestBundle for an agent. | |||
type ManifestCodec struct { | |||
restMapper meta.RESTMapper | |||
sequenceGenerator *snowflake.Node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is only needed for status update, right? I do not think a developer of consumer need to care about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, the agent generates the sequence id only when it creates the status update event.
and creating the snowflake generator when the agent init
cloudevents/generic/types/types.go
Outdated
@@ -48,6 +48,10 @@ const ( | |||
// ExtensionResourceVersion is the cloud event extension key of the resource version. | |||
ExtensionResourceVersion = "resourceversion" | |||
|
|||
// ExtensionSequenceID is the cloud event extension key of the event sequence ID. | |||
// The event sequence id represents the order in which events occur on the agent/source. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not the strict order. I think you can only use it to order the event from one single agent. I do not think you need this for source.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, the source does not need this, it already has resoruceversion, update the description and variable name to make this more clear
|
||
func init() { | ||
// init the snowflake id generator, for each single agent, they send events independently, we set the snowflake | ||
// node id to 1 for one single agent, that means, we can sort events sent by the same agent. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// node id to 1 for one single agent, that means, we can sort events sent by the same agent. | |
// init the snowflake id generator with node id 1 for each single agent. | |
// Each single agent has its own consumer id to be identified, and we | |
// can ensure the order of status update event from the same agent via | |
// sequence id. The events from different agents are independent, hence | |
// the ordering among them needs not to be guaranteed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update the comment, others look good
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: qiujian16, skeeey The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: Wei Liu <liuweixa@redhat.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
550ac68
into
open-cluster-management-io:main
Summary
Related issue(s)
Fixes #