rsop
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package rsop facilitatessource.Store registration viaRegisterStoreand provides access to the effective policy merged from all registered sourcesviaPolicyFor.
Index¶
- Variables
- type Change
- type Policy
- func (p *Policy) Close()
- func (p *Policy) Done() <-chan struct{}
- func (p *Policy) Get() *setting.Snapshot
- func (p *Policy) IsValid() bool
- func (p *Policy) RegisterChangeCallback(callback PolicyChangeCallback) (unregister func())
- func (p *Policy) Reload() (*setting.Snapshot, error)
- func (p *Policy) Scope() setting.PolicyScope
- type PolicyChange
- type PolicyChangeCallback
- type StoreRegistration
Constants¶
This section is empty.
Variables¶
var ErrAlreadyConsumed =errors.New("the store registration is no longer valid")ErrAlreadyConsumed is the error returned whenStoreRegistration.ReplaceStoreorStoreRegistration.Unregister is called more than once.
var ErrPolicyClosed =errors.New("effective policy closed")ErrPolicyClosed is returned byPolicy.Reload, [Policy.addSource],[Policy.removeSource] and [Policy.replaceSource] if the policy has been closed.
Functions¶
This section is empty.
Types¶
typeChange¶
type Change[Tany] struct {New, Old T}
Change represents a change from the Old to the New value of type T.
typePolicy¶
type Policy struct {// contains filtered or unexported fields}Policy provides access to the current effectivesetting.Snapshot for a givenscope and allows to reload it from the underlyingsource.Store list. It also allows tosubscribe and receive a callback whenever the effectivesetting.Snapshot is changed.
It is safe for concurrent use.
funcPolicyFor¶
func PolicyFor(scopesetting.PolicyScope) (*Policy,error)
PolicyFor returns thePolicy for the specified scope,creating it from the registered [source.Store]s if it doesn't already exist.
func (*Policy)Close¶
func (p *Policy) Close()
Close initiates the closing of the policy.ThePolicy.Done channel is closed to signal that the operation has been completed.
func (*Policy)Done¶
func (p *Policy) Done() <-chan struct{}
Done returns a channel that is closed when thePolicy is closed.
func (*Policy)Get¶
Get returns the effectivesetting.Snapshot.
func (*Policy)IsValid¶
IsValid reports whether p is in a valid state and has not been closed.
Since p's state can be changed by other goroutines at any time, this shouldonly be used as an optimization.
func (*Policy)RegisterChangeCallback¶
func (p *Policy) RegisterChangeCallback(callbackPolicyChangeCallback) (unregister func())
RegisterChangeCallback adds a function to be called whenever the effectivepolicy changes. The returned function can be used to unregister the callback.
func (*Policy)Reload¶
Reload synchronously re-reads policy settings from the underlying list of policy sources,constructing a new mergedsetting.Snapshot even if the policy remains unchanged.In most scenarios, there's no need to re-read the policy manually.Instead, it is recommended to register a policy change callback, or to usethe most recentsetting.Snapshot returned by thePolicy.Get method.
It must not be called with p.mu held.
func (*Policy)Scope¶
func (p *Policy) Scope()setting.PolicyScope
Scope returns thesetting.PolicyScope that this policy applies to.
typePolicyChange¶
type PolicyChange struct {// contains filtered or unexported fields}PolicyChange describes a policy change.
func (PolicyChange)HasChanged¶
func (cPolicyChange) HasChanged(keypkey.Key)bool
HasChanged reports whether a policy setting with the specifiedpkey.Key, has changed.
func (PolicyChange)HasChangedAnyOf¶added inv1.86.0
func (cPolicyChange) HasChangedAnyOf(keys ...pkey.Key)bool
HasChangedAnyOf reports whether any of the specified policy settings has changed.
func (PolicyChange)New¶
func (cPolicyChange) New() *setting.Snapshot
New returns thesetting.Snapshot after the change.
func (PolicyChange)Old¶
func (cPolicyChange) Old() *setting.Snapshot
Old returns thesetting.Snapshot before the change.
typePolicyChangeCallback¶
type PolicyChangeCallback func(policyclient.PolicyChange)
PolicyChangeCallback is a function called whenever a policy changes.
typeStoreRegistration¶
type StoreRegistration struct {// contains filtered or unexported fields}StoreRegistration is asource.Store registered for use in the specified scope.It can be used to unregister the store, or replace it with another one.
funcRegisterStore¶
func RegisterStore(namestring, scopesetting.PolicyScope, storesource.Store) (*StoreRegistration,error)
RegisterStore registers a new policysource.Store with the specified name andsetting.PolicyScope.
funcRegisterStoreForTest¶
func RegisterStoreForTest(tbtestenv.TB, namestring, scopesetting.PolicyScope, storesource.Store) (*StoreRegistration,error)
RegisterStoreForTest is likeRegisterStore, but unregisters the store whentb and all its subtests complete.
func (*StoreRegistration)ReplaceStore¶
func (r *StoreRegistration) ReplaceStore(newsource.Store) (*StoreRegistration,error)
ReplaceStore replaces the registered store with the new one,returning a newStoreRegistration or an error.
func (*StoreRegistration)Unregister¶
func (r *StoreRegistration) Unregister()error
Unregister reverts the registration.