-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
service: add Getters and Validate, Require methods for task, event an…
- Loading branch information
Showing
14 changed files
with
280 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package service | ||
|
||
// GetEvent returns event eventKey. | ||
func (s *Service) GetEvent(eventKey string) (*Event, error) { | ||
event, ok := s.Events[eventKey] | ||
if !ok { | ||
return nil, &EventNotFoundError{ | ||
EventKey: eventKey, | ||
ServiceName: s.Name, | ||
} | ||
} | ||
return event, nil | ||
} | ||
|
||
// ValidateData validates event data to match with paremeter config. | ||
func (e *Event) ValidateData(eventData map[string]interface{}) []*ParameterWarning { | ||
return validateParametersSchema(e.Data, eventData) | ||
} | ||
|
||
// RequireData requires event data to match with paremeter config. | ||
func (e *Event) RequireData(eventData map[string]interface{}) error { | ||
warnings := e.ValidateData(eventData) | ||
if len(warnings) > 0 { | ||
return &InvalidEventDataError{ | ||
EventKey: e.Key, | ||
ServiceName: e.ServiceName, | ||
Warnings: warnings, | ||
} | ||
} | ||
return nil | ||
} |
Oops, something went wrong.