Skip to content

Commit

Permalink
Merge pull request #67 from Clever/use-projection-expression-for-summary
Browse files Browse the repository at this point in the history
use ddb projection expression for summaryOnly=true
  • Loading branch information
mohit authored Oct 13, 2017
2 parents 107c8a4 + 53e83d2 commit 0fc1d9d
Show file tree
Hide file tree
Showing 16 changed files with 464 additions and 245 deletions.
12 changes: 10 additions & 2 deletions executor/log_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,22 @@ func TestDataResultsRouting(t *testing.T) {
assert.Equal(0, len(counts))

t.Log("matches 'job-status-alerts'")
logJobStatus(&models.Job{}, &models.Workflow{WorkflowDefinition: &models.WorkflowDefinition{}})
logJobStatus(&models.Job{}, &models.Workflow{
WorkflowSummary: models.WorkflowSummary{
WorkflowDefinition: &models.WorkflowDefinition{},
}},
)
counts = mocklog.RuleCounts()
assert.Equal(1, len(counts))
assert.Contains(counts, "job-status-alerts")
assert.Equal(counts["job-status-alerts"], 1)

t.Log("matches 'workflow-status-change'")
logWorkflowStatusChange(&models.Workflow{WorkflowDefinition: &models.WorkflowDefinition{}}, models.WorkflowStatusRunning)
logWorkflowStatusChange(&models.Workflow{
WorkflowSummary: models.WorkflowSummary{
WorkflowDefinition: &models.WorkflowDefinition{},
}},
models.WorkflowStatusRunning)
counts = mocklog.RuleCounts()
assert.Equal(3, len(counts))
assert.Contains(counts, "workflow-status-metrics")
Expand Down
10 changes: 8 additions & 2 deletions gen-go/models/inputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func (i GetWorkflowDefinitionByNameAndVersionInput) Path() (string, error) {

// GetWorkflowsInput holds the input parameters for a getWorkflows operation.
type GetWorkflowsInput struct {
Limit *int32
Limit *int64
OldestFirst *bool
PageToken *string
Status *string
Expand All @@ -298,6 +298,12 @@ type GetWorkflowsInput struct {
// requirements from the swagger yml file.
func (i GetWorkflowsInput) Validate() error {

if i.Limit != nil {
if err := validate.MaximumInt("limit", "query", *i.Limit, int64(10000), false); err != nil {
return err
}
}

return nil
}

Expand All @@ -307,7 +313,7 @@ func (i GetWorkflowsInput) Path() (string, error) {
urlVals := url.Values{}

if i.Limit != nil {
urlVals.Add("limit", strconv.FormatInt(int64(*i.Limit), 10))
urlVals.Add("limit", strconv.FormatInt(*i.Limit, 10))
}

if i.OldestFirst != nil {
Expand Down
92 changes: 3 additions & 89 deletions gen-go/models/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,68 +13,24 @@ import (
// Workflow workflow
// swagger:model Workflow
type Workflow struct {

// created at
CreatedAt strfmt.DateTime `json:"createdAt,omitempty"`

// id
ID string `json:"id,omitempty"`

// input
Input string `json:"input,omitempty"`
WorkflowSummary

// jobs
Jobs []*Job `json:"jobs"`

// last updated
LastUpdated strfmt.DateTime `json:"lastUpdated,omitempty"`

// namespace
Namespace string `json:"namespace,omitempty"`

// queue
Queue string `json:"queue,omitempty"`

// workflow-id's of workflows created as retries for this workflow
Retries []string `json:"retries"`

// workflow-id of original workflow in case this is a retry
RetryFor string `json:"retryFor,omitempty"`

// status
Status WorkflowStatus `json:"status,omitempty"`

// status reason
StatusReason string `json:"statusReason,omitempty"`

// tags: object with key-value pairs; keys and values should be strings
Tags map[string]interface{} `json:"tags,omitempty"`

// workflow definition
WorkflowDefinition *WorkflowDefinition `json:"workflowDefinition,omitempty"`
}

// Validate validates this workflow
func (m *Workflow) Validate(formats strfmt.Registry) error {
var res []error

if err := m.validateJobs(formats); err != nil {
// prop
if err := m.WorkflowSummary.Validate(formats); err != nil {
res = append(res, err)
}

if err := m.validateRetries(formats); err != nil {
// prop
res = append(res, err)
}

if err := m.validateStatus(formats); err != nil {
// prop
res = append(res, err)
}

if err := m.validateWorkflowDefinition(formats); err != nil {
// prop
if err := m.validateJobs(formats); err != nil {
res = append(res, err)
}

Expand All @@ -86,10 +42,6 @@ func (m *Workflow) Validate(formats strfmt.Registry) error {

func (m *Workflow) validateJobs(formats strfmt.Registry) error {

if swag.IsZero(m.Jobs) { // not required
return nil
}

for i := 0; i < len(m.Jobs); i++ {

if swag.IsZero(m.Jobs[i]) { // not required
Expand All @@ -107,41 +59,3 @@ func (m *Workflow) validateJobs(formats strfmt.Registry) error {

return nil
}

func (m *Workflow) validateRetries(formats strfmt.Registry) error {

if swag.IsZero(m.Retries) { // not required
return nil
}

return nil
}

func (m *Workflow) validateStatus(formats strfmt.Registry) error {

if swag.IsZero(m.Status) { // not required
return nil
}

if err := m.Status.Validate(formats); err != nil {
return err
}

return nil
}

func (m *Workflow) validateWorkflowDefinition(formats strfmt.Registry) error {

if swag.IsZero(m.WorkflowDefinition) { // not required
return nil
}

if m.WorkflowDefinition != nil {

if err := m.WorkflowDefinition.Validate(formats); err != nil {
return err
}
}

return nil
}
97 changes: 97 additions & 0 deletions gen-go/models/workflow_query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package models

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"

"github.com/go-openapi/errors"
"github.com/go-openapi/validate"
)

// WorkflowQuery workflow query
// swagger:model WorkflowQuery
type WorkflowQuery struct {

// limit
// Maximum: 10000
Limit int64 `json:"limit,omitempty"`

// oldest first
OldestFirst bool `json:"oldestFirst,omitempty"`

// page token
PageToken string `json:"pageToken,omitempty"`

// status
Status WorkflowStatus `json:"status,omitempty"`

// summary only
SummaryOnly *bool `json:"summaryOnly,omitempty"`

// workflow definition name
// Required: true
WorkflowDefinitionName *string `json:"workflowDefinitionName"`
}

// Validate validates this workflow query
func (m *WorkflowQuery) Validate(formats strfmt.Registry) error {
var res []error

if err := m.validateLimit(formats); err != nil {
// prop
res = append(res, err)
}

if err := m.validateStatus(formats); err != nil {
// prop
res = append(res, err)
}

if err := m.validateWorkflowDefinitionName(formats); err != nil {
// prop
res = append(res, err)
}

if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

func (m *WorkflowQuery) validateLimit(formats strfmt.Registry) error {

if swag.IsZero(m.Limit) { // not required
return nil
}

if err := validate.MaximumInt("limit", "body", int64(m.Limit), 10000, false); err != nil {
return err
}

return nil
}

func (m *WorkflowQuery) validateStatus(formats strfmt.Registry) error {

if swag.IsZero(m.Status) { // not required
return nil
}

if err := m.Status.Validate(formats); err != nil {
return err
}

return nil
}

func (m *WorkflowQuery) validateWorkflowDefinitionName(formats strfmt.Registry) error {

if err := validate.Required("workflowDefinitionName", "body", m.WorkflowDefinitionName); err != nil {
return err
}

return nil
}
112 changes: 112 additions & 0 deletions gen-go/models/workflow_summary.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package models

// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

import (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"

"github.com/go-openapi/errors"
)

// WorkflowSummary workflow summary
// swagger:model WorkflowSummary
type WorkflowSummary struct {

// created at
CreatedAt strfmt.DateTime `json:"createdAt,omitempty"`

// id
ID string `json:"id,omitempty"`

// input
Input string `json:"input,omitempty"`

// last updated
LastUpdated strfmt.DateTime `json:"lastUpdated,omitempty"`

// namespace
Namespace string `json:"namespace,omitempty"`

// queue
Queue string `json:"queue,omitempty"`

// workflow-id's of workflows created as retries for this workflow
Retries []string `json:"retries"`

// workflow-id of original workflow in case this is a retry
RetryFor string `json:"retryFor,omitempty"`

// status
Status WorkflowStatus `json:"status,omitempty"`

// tags: object with key-value pairs; keys and values should be strings
Tags map[string]interface{} `json:"tags,omitempty"`

// workflow definition
WorkflowDefinition *WorkflowDefinition `json:"workflowDefinition,omitempty"`
}

// Validate validates this workflow summary
func (m *WorkflowSummary) Validate(formats strfmt.Registry) error {
var res []error

if err := m.validateRetries(formats); err != nil {
// prop
res = append(res, err)
}

if err := m.validateStatus(formats); err != nil {
// prop
res = append(res, err)
}

if err := m.validateWorkflowDefinition(formats); err != nil {
// prop
res = append(res, err)
}

if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}

func (m *WorkflowSummary) validateRetries(formats strfmt.Registry) error {

if swag.IsZero(m.Retries) { // not required
return nil
}

return nil
}

func (m *WorkflowSummary) validateStatus(formats strfmt.Registry) error {

if swag.IsZero(m.Status) { // not required
return nil
}

if err := m.Status.Validate(formats); err != nil {
return err
}

return nil
}

func (m *WorkflowSummary) validateWorkflowDefinition(formats strfmt.Registry) error {

if swag.IsZero(m.WorkflowDefinition) { // not required
return nil
}

if m.WorkflowDefinition != nil {

if err := m.WorkflowDefinition.Validate(formats); err != nil {
return err
}
}

return nil
}
Loading

0 comments on commit 0fc1d9d

Please sign in to comment.