-
Notifications
You must be signed in to change notification settings - Fork 13
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
Create event api #1126
Create event api #1126
Conversation
c625c3e
to
46beb9f
Compare
} | ||
|
||
// CreateEventRequest defines request for execution update. | ||
message CreateEventRequest { |
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.
you could change the message CreateEventRequest
to:
message CreateEventRequest {
// instanceHash is hash of instance that can proceed an execution.
string instanceHash = 1;
// key is the key of the event.
string key = 2;
// data is the data for the event.
string data = 3;
}
So there is not need to check for a not empty hash in server/grpc/api/event.go
Also I think it's more logic to have different messages to create the resource and to return it.
The same modification should be done (but in a future time) on ServiceX/Create. Reusing the definition.service causes more problem than it solves.
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.
// The request's data for the `Create` API.
message CreateServiceRequest {
definition.Service definition = 1; // The service definition to use to create the Service.
}
We accept service in servcie api, so I wanted to be consistent. And I prefer to check if hash is empty rather then redefine all event fields (same for CreateServiceRequest
). It's more clear that CreateEventRquest expects event as argument.
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.
The following issue is actually to change CreateServiceRequest
: #1111
@@ -31,26 +31,25 @@ func New(ps *pubsub.PubSub, service *servicesdk.Service, instance *instancesdk.I | |||
} | |||
|
|||
// Emit emits a MESG event eventKey with eventData for service token. | |||
func (e *Event) Emit(instanceHash hash.Hash, eventKey string, eventData map[string]interface{}) error { | |||
func (e *Event) Emit(instanceHash hash.Hash, eventKey string, eventData map[string]interface{}) (*event.Event, error) { |
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.
func (e *Event) Emit(instanceHash hash.Hash, eventKey string, eventData map[string]interface{}) (*event.Event, error) { | |
func (e *Event) Emit(evnt *event.Event) (error) { |
what about changing the parameters of this function to directly accept the event struct?
I think it will make this function a bit simpler as well as the api package.
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.
It's fine like that, otherwise, we will still have the confusion between the actual inputs and the resource itself which is not good. We will have the same problem that we have with the service.create
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.
I'm ok with both - just another thing we can make consistent accross source code.
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.
The function create in serviceSDK accept directly the service:
func (s *Service) Create(srv *service.Service) (*service.Service, error) {
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.
Can I upadte this when I'm going to remove coreapi methods?
@@ -31,26 +31,25 @@ func New(ps *pubsub.PubSub, service *servicesdk.Service, instance *instancesdk.I | |||
} | |||
|
|||
// Emit emits a MESG event eventKey with eventData for service token. | |||
func (e *Event) Emit(instanceHash hash.Hash, eventKey string, eventData map[string]interface{}) error { | |||
func (e *Event) Emit(instanceHash hash.Hash, eventKey string, eventData map[string]interface{}) (*event.Event, error) { |
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.
It's fine like that, otherwise, we will still have the confusion between the actual inputs and the resource itself which is not good. We will have the same problem that we have with the service.create
Co-Authored-By: Anthony <[email protected]> Co-Authored-By: Nicolas Mahé <[email protected]>
da476a8
to
50bfaa4
Compare
No description provided.