-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 from suborbital/connor/capability-config
Add ability to configure individual capabilities
- Loading branch information
Showing
18 changed files
with
335 additions
and
75 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,56 @@ | ||
package rcap | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
"github.com/suborbital/vektor/vlog" | ||
) | ||
|
||
var ErrCapabilityNotEnabled = errors.New("capability is not enabled") | ||
|
||
// CapabilityConfig is configuration for a Runnable's capabilities | ||
// NOTE: if any of the individual configs are nil, it will cause a crash, | ||
// but we need to be able to determine if they're set or not, hence the pointers | ||
// we are going to leave capabilities undocumented until we come up with a more elegant solution | ||
type CapabilityConfig struct { | ||
Logger *LoggerConfig `json:"logger,omitempty" yaml:"logger,omitempty"` | ||
HTTP *HTTPConfig `json:"http,omitempty" yaml:"http,omitempty"` | ||
GraphQL *GraphQLConfig `json:"graphql,omitempty" yaml:"graphql,omitempty"` | ||
Auth *AuthConfig `json:"auth,omitempty" yaml:"auth,omitempty"` | ||
Cache *CacheConfig `json:"cache,omitempty" yaml:"cache,omitempty"` | ||
File *FileConfig `json:"file,omitempty" yaml:"file,omitempty"` | ||
RequestHandler *RequestHandlerConfig `json:"requestHandler,omitempty" yaml:"requestHandler,omitempty"` | ||
} | ||
|
||
// DefaultCapabilityConfig returns the default all-enabled config (with a default logger) | ||
func DefaultCapabilityConfig() CapabilityConfig { | ||
return DefaultConfigWithLogger(vlog.Default()) | ||
} | ||
|
||
func DefaultConfigWithLogger(logger *vlog.Logger) CapabilityConfig { | ||
c := CapabilityConfig{ | ||
Logger: &LoggerConfig{ | ||
Enabled: true, | ||
Logger: logger, | ||
}, | ||
HTTP: &HTTPConfig{ | ||
Enabled: true, | ||
}, | ||
GraphQL: &GraphQLConfig{ | ||
Enabled: true, | ||
}, | ||
Auth: &AuthConfig{ | ||
Enabled: true, | ||
}, | ||
Cache: &CacheConfig{ | ||
Enabled: true, | ||
}, | ||
File: &FileConfig{ | ||
Enabled: true, | ||
}, | ||
RequestHandler: &RequestHandlerConfig{ | ||
Enabled: true, | ||
}, | ||
} | ||
|
||
return c | ||
} |
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
Oops, something went wrong.