-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add table and plugin level defaults for ShouldIgnoreError and RetryCo…
…nfig. Closes #257
- Loading branch information
1 parent
8d0ee5c
commit cf18abf
Showing
18 changed files
with
492 additions
and
96 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package plugin | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/turbot/go-kit/helpers" | ||
) | ||
|
||
// HydrateConfig defines the hydrate function configurations, Name, Maximum number of concurrent calls to be allowed, dependencies | ||
type HydrateConfig struct { | ||
Func HydrateFunc | ||
MaxConcurrency int | ||
RetryConfig *RetryConfig | ||
|
||
ShouldIgnoreError ErrorPredicate | ||
Depends []HydrateFunc | ||
} | ||
|
||
func (c *HydrateConfig) DefaultTo(defaultConfig *HydrateConfig) { | ||
if defaultConfig == nil { | ||
return | ||
} | ||
if c.RetryConfig == nil { | ||
c.RetryConfig = defaultConfig.RetryConfig | ||
} | ||
if c.Depends == nil { | ||
c.Depends = defaultConfig.Depends | ||
} | ||
} | ||
|
||
func (c *HydrateConfig) String() interface{} { | ||
shouldIgnoreErrorString := "" | ||
if c.ShouldIgnoreError != nil { | ||
shouldIgnoreErrorString = helpers.GetFunctionName(c.Func) | ||
} | ||
var dependsStrings = make([]string, len(c.Depends)) | ||
for i, dep := range c.Depends { | ||
dependsStrings[i] = helpers.GetFunctionName(dep) | ||
} | ||
return fmt.Sprintf(`Func: %s | ||
MaxConcurrency: %d | ||
RetryConfig: %s | ||
ShouldIgnoreError: %s | ||
Depends: %s`, | ||
helpers.GetFunctionName(c.Func), | ||
c.MaxConcurrency, | ||
c.RetryConfig.String(), | ||
shouldIgnoreErrorString, | ||
strings.Join(dependsStrings, ",")) | ||
} |
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,9 @@ | ||
package plugin | ||
|
||
// HydrateData contains the input data passed to every hydrate function | ||
type HydrateData struct { | ||
// if there was a parent-child list call, store the parent list item | ||
ParentItem interface{} | ||
Item interface{} | ||
HydrateResults map[string]interface{} | ||
} |
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,8 @@ | ||
package plugin | ||
|
||
// HydrateDependencies defines the hydrate function dependencies - other hydrate functions which must be run first | ||
// Deprecated: used HydrateConfig | ||
type HydrateDependencies struct { | ||
Func HydrateFunc | ||
Depends []HydrateFunc | ||
} |
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,8 @@ | ||
package plugin | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
// HydrateFunc is a function which retrieves some or all row data for a single row item. | ||
type HydrateFunc func(context.Context, *QueryData, *HydrateData) (interface{}, error) |
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,15 @@ | ||
package plugin | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/turbot/go-kit/helpers" | ||
) | ||
|
||
type RetryConfig struct { | ||
ShouldRetryError ErrorPredicate | ||
} | ||
|
||
func (c RetryConfig) String() interface{} { | ||
return fmt.Sprintf("ShouldRetryError: %s", helpers.GetFunctionName(c.ShouldRetryError)) | ||
} |
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
Oops, something went wrong.