Documentation
¶
Overview ¶
Do not edit mock_Plugin_Closer.go directly as your changes will be overwritten. Instead, edit mock_Plugin_Closer.go.src and re-run "go generate ./" in the root SDK package.
Package sdk contains the low-level interfaces and API for creating Sentinel plugins. A Sentinel plugin can provide data dynamically to Sentinel policies.
For plugin authors, the subfolder "framework" contains a high-level framework for easily implementing plugins in Go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Undefined is a constant value that represents the undefined object in // Sentinel. By making this the return value, it'll be converted to // Undefined. Undefined = &undefined{} // Null is a constant value that represents the null object in Sentinel. // By making this a return value, it will convert to null. Null = &null{} )
Functions ¶
This section is empty.
Types ¶
type GetKey ¶
type GetKey struct {
// The key for this part of the request.
Key string
// The list of arguments for a call expression. This is "nil" if
// this key is not a call. This may be length zero (but non-nil) if
// this is a call with no arguments.
Args []interface{}
}
GetKey is an individual key in the larger possible selector of the specific plugin call, along with any supplied arguments for the specific key.
type GetReq ¶
type GetReq struct {
// ExecId is a unique ID representing the particular execution for this
// request. This can be used to maintain state locally.
//
// ExecDeadline is a hint of when the execution will be over and the
// state can be thrown away. The time given here will always be in UTC
// time. Note that this is susceptible to clock shifts, but Go is planning
// to make the time APIs monotonic by default (see proposal 12914). After
// that this will be resolved.
ExecId uint64
ExecDeadline time.Time
// Keys is the list of keys being requested. For example for "a.b.c"
// where "a" is the plugin, Keys would be ["b", "c"].
Keys []GetKey
// KeyId is a unique ID for this key. This should match exactly the
// GetResult KeyId so that the result for this can be found quickly.
KeyId uint64
// Context, if supplied, is an arbitrary object intended to
// represent the data from an existing namespace. If the plugin
// supports the framework.New interface, the contents are passed to
// it, with any resulting namespace being what Get operates on.
//
// The Get call operates on the root of the plugin if this is set
// to nil. If this is set and the plugin does not implement
// framework.New, an error is returned.
Context map[string]interface{}
}
GetReq are the arguments given to Get for an Plugin.
type GetResult ¶
type GetResult struct {
KeyId uint64 // KeyId matching GetReq.KeyId, or zero.
Keys []string // Keys structure from GetReq.Keys, or new key set.
Value interface{} // Value compatible with lang/object.ToObject
Context map[string]interface{} // Updated Context if it was sent
Callable bool // true if returned Value is callable
}
GetResult is the result structure for a Get request.
type GetResultList ¶
type GetResultList []*GetResult
GetResultList is a wrapper around a slice of GetResult structures to provide helpers.
func (GetResultList) KeyId ¶
func (r GetResultList) KeyId(id uint64) *GetResult
KeyId gets the result with the given key ID, or nil if its not found.
type MockPlugin ¶ added in v0.4.0
MockPlugin is an autogenerated mock type for the Plugin type
func NewMockPlugin ¶ added in v0.4.0
func NewMockPlugin(t mockConstructorTestingTNewMockPlugin) *MockPlugin
NewMockPlugin creates a new instance of MockPlugin. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
func (*MockPlugin) Configure ¶ added in v0.4.0
func (_m *MockPlugin) Configure(_a0 map[string]interface{}) error
Configure provides a mock function with given fields: _a0
type MockPluginCloser ¶ added in v0.4.0
type MockPluginCloser struct {
MockPlugin
}
MockPluginCloser augments MockPlugin to also implement io.Closer
func (*MockPluginCloser) Close ¶ added in v0.4.0
func (_m *MockPluginCloser) Close() error
Close mocks Close for MockPluginCloser
type Plugin ¶ added in v0.4.0
type Plugin interface {
// Configure is called to configure the plugin before it is accessed.
// This must be called before any call to Get().
Configure(map[string]interface{}) error
// Get is called when an plugin field is accessed or called as a function.
//
// Get may request more than one value at a time, represented by multiple
// GetReq values. The result GetResult should contain the matching
// KeyId for the requests.
//
// The result value is not a map keyed on KeyId to allow flexibility
// in the future of potentially allowing pre-fetched data. This has no
// effect currently.
Get(reqs []*GetReq) ([]*GetResult, error)
}
Plugin is an importable package.
Plugins are a namespace that may contain objects and functions. The root level has no value nor can it be called. For example `import "a'` allows access to fields within "a" such as `a.b` but doesn't allow referencing or calling it directly with `a` alone. This is an important difference between plugins and external objects (which themselves express a value).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package framework contains a high-level framework for implementing Sentinel plugins with Go.
|
Package framework contains a high-level framework for implementing Sentinel plugins with Go. |
|
proto
|
|
|
go
Package proto contains the Go generated files for the protocol buffer files.
|
Package proto contains the Go generated files for the protocol buffer files. |
|
Package rpc contains the API that can be used to serve Sentinel plugins over an RPC interface.
|
Package rpc contains the API that can be used to serve Sentinel plugins over an RPC interface. |
|
Package testing provides support for automated testing for plugins.
|
Package testing provides support for automated testing for plugins. |
|
testplugin
Package testplugin contains a test plugin that the testing package uses for unit tests.
|
Package testplugin contains a test plugin that the testing package uses for unit tests. |