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

✨ add grpc option for cloudevents client. #302

Conversation

morvencao
Copy link
Member

Summary

This PR tries to add gRPC option for cloudevents client.

Related issue(s)

Fixes #

Signed-off-by: morvencao <lcao@redhat.com>
@morvencao morvencao marked this pull request as ready for review December 13, 2023 13:52
Signed-off-by: morvencao <lcao@redhat.com>
Signed-off-by: morvencao <lcao@redhat.com>
return &GRPCOptions{}
}

func (o *GRPCOptions) AddFlags(flags *pflag.FlagSet) {
Copy link
Member

Choose a reason for hiding this comment

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

I think this should also be in the config similar as mqtt. It will be better it we share the same config file.

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 the grpc options to use config similar to mqtt.

Signed-off-by: morvencao <lcao@redhat.com>

package io.cloudevents.v1;

option go_package = "open-cluster-management.io/api/cloudevents/generic/options/grpc/protobuf/v1";
Copy link
Member

Choose a reason for hiding this comment

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

what is needed if the protobuf message is changed? We need some readme to explain.

Copy link
Member Author

Choose a reason for hiding this comment

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

added a readme file and some comments to guide developer how to update go code after modifying the proto file.

Signed-off-by: morvencao <lcao@redhat.com>
"open-cluster-management.io/api/cloudevents/generic/options/grpc/protocol"
)

const (
Copy link
Member

Choose a reason for hiding this comment

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

move these topics to a common file?

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently, the topic structure for gRPC aligns with MQTT, but when we have a third option like Kafka, that would need a distinct pattern for topics. In that case, a common file for topics becomes unfeasible, make sense?

Copy link
Member

Choose a reason for hiding this comment

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

yeah, but I think the ideal situation is to have unified topics :), we can keep the topics in each option firstly

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, let's organize topics within each option for now and and see if we can have a unified topics in the future.

}

func (o *grpcAgentOptions) WithContext(ctx context.Context, evtCtx cloudevents.EventContext) (context.Context, error) {
eventType, err := types.ParseCloudEventsType(evtCtx.GetType())
Copy link
Member

Choose a reason for hiding this comment

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

do we need this for grpc?

Copy link
Member Author

Choose a reason for hiding this comment

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

We require this information to assign the topic for event publish, and the topic will be included in the gRPC publish request, see:

message PublishRequest {
// Required. The topic to which event should be published.
// Format is `myhome/groundfloor/livingroom/temperature`.
string topic = 1;
CloudEvent event = 2;
}

@@ -0,0 +1,30 @@
# CloudEvent gRPC Protobuf Definitions
Copy link
Member

Choose a reason for hiding this comment

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

would you also link this in the https://github.com/open-cluster-management-io/api/blob/main/cloudevents/README.md, we have a client introduction in this doc, you can add a new option in the CloudEventsOptions, it provides ...

Copy link
Member Author

Choose a reason for hiding this comment

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

Added grpc option to cloudevents/README.md

Signed-off-by: morvencao <lcao@redhat.com>
@qiujian16
Copy link
Member

/approve

Copy link
Contributor

openshift-ci bot commented Dec 19, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: morvencao, qiujian16

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@skeeey
Copy link
Member

skeeey commented Dec 19, 2023

/lgtm

@openshift-merge-bot openshift-merge-bot bot merged commit a2f58d6 into open-cluster-management-io:main Dec 19, 2023
15 checks passed
@morvencao morvencao deleted the br_cloudevents_grpc_option branch December 19, 2023 03:01
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.

None yet

4 participants