datastore

package
v0.0.47 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// to be used for candidates created without an owner
	DefaultOwner = "__sdcio"
)

Variables

View Source
var ErrIntentNotFound = errors.New("intent not found")

Functions

This section is empty.

Types

type Datastore

type Datastore struct {
	// contains filtered or unexported fields
}

func New

New creates a new datastore, its schema server client and initializes the SBI target func New(c *config.DatastoreConfig, schemaServer *config.RemoteSchemaServer) *Datastore {

func (*Datastore) Candidates

func (d *Datastore) Candidates(ctx context.Context) ([]*sdcpb.DataStore, error)

func (*Datastore) Config

func (d *Datastore) Config() *config.DatastoreConfig

func (*Datastore) ConnectionState

func (d *Datastore) ConnectionState() string

func (*Datastore) CreateCandidate

func (d *Datastore) CreateCandidate(ctx context.Context, ds *sdcpb.DataStore) error

func (*Datastore) DeleteCache

func (d *Datastore) DeleteCache(ctx context.Context) error

func (*Datastore) DeleteCandidate

func (d *Datastore) DeleteCandidate(ctx context.Context, name string) error

func (*Datastore) DeviationMgr

func (d *Datastore) DeviationMgr(ctx context.Context)

func (*Datastore) Diff

func (*Datastore) Discard

func (d *Datastore) Discard(ctx context.Context, req *sdcpb.DiscardRequest) error

func (*Datastore) Get

func (d *Datastore) Get(ctx context.Context, req *sdcpb.GetDataRequest, nCh chan *sdcpb.GetDataResponse) error

func (*Datastore) GetIntent

func (*Datastore) ListIntent

func (*Datastore) Name

func (d *Datastore) Name() string

func (*Datastore) Rebase

func (d *Datastore) Rebase(ctx context.Context, req *sdcpb.RebaseRequest) error

func (*Datastore) Schema

func (d *Datastore) Schema() *config.SchemaConfig

func (*Datastore) Set

func (*Datastore) SetIntent

func (*Datastore) SetIntentUpdate

func (d *Datastore) SetIntentUpdate(ctx context.Context, req *sdcpb.SetIntentRequest, candidateName string) (*sdcpb.SetIntentResponse, error)

SetIntentUpdate Processes new and updated intents

The main concept is as follows.

  1. Get all keys from the cache along with the "metadata" (Owner, Priority, etc.) Note: Requesting the values is the expensive task with the default cache implementation
  2. Filter the keys for entries that belong to the intent (Owner) which is necessary for updated intents (delete config entries that do no longer exist)
  3. Calculate all the paths that the new intent request touches
  4. Combine the keys from the two previous steps to query them from the cache just once.
  5. Query the cache with the resulting keys to also get the values.
  6. Add the received cache entries to the tree with the new-flag set to false.
  7. Mark all entries in the tree for the specific owner as deleted.
  8. Add all the new request entries to the tree with the new flag set to true. The tree will evaluate the values and adjust its internal state (new, deleted and updated) for these entries. If the value remains unchanged, it will reset the new flag if it is a different value, it will set the updated flag and reset the delete flag.
  9. The tree will be populated with schema information.
  10. Now the tree can be queried for the highes priority values ".GetHighesPrio(true)". It will also consider the deleted flag and only return new or updated values. This is the calculation the yields the updates that will need to be pushed to the device.
  11. .GetDeletes() returns the entries that are still marked for deletion. The Paths will be extracted and then send to the device as deletes (path aggregation is applied, if e.g. a whole interface is delted, the deleted paths only contains the delete for the interface, not all its leafs)
  12. All updates (New & Updated) for the specifc owner / intent are being retrieved from the tree to update the cache.
  13. All remaining deletes for the specifc owner / intent are being retrieved from the tree to remove them from the cache.
  14. The request towards southbound is created with the device updates / deletes. A candidate is created, and applied to the device.
  15. The owner based updates and deletes are being pushed into the cache.
  16. The raw intent (as received in the req) is stored as a blob in the cache.

func (*Datastore) Stop

func (d *Datastore) Stop() error

func (*Datastore) StopDeviationsWatch

func (d *Datastore) StopDeviationsWatch(peer string)

func (*Datastore) Subscribe

func (*Datastore) Sync

func (d *Datastore) Sync(ctx context.Context)

func (*Datastore) WatchDeviations

type SdcpbUpdateDedup added in v0.0.43

type SdcpbUpdateDedup struct {
	// contains filtered or unexported fields
}

func NewSdcpbUpdateDedup added in v0.0.43

func NewSdcpbUpdateDedup() *SdcpbUpdateDedup

func (*SdcpbUpdateDedup) AddUpdate added in v0.0.43

func (s *SdcpbUpdateDedup) AddUpdate(upd *sdcpb.Update)

func (*SdcpbUpdateDedup) AddUpdates added in v0.0.43

func (s *SdcpbUpdateDedup) AddUpdates(upds []*sdcpb.Update)

func (*SdcpbUpdateDedup) Updates added in v0.0.43

func (s *SdcpbUpdateDedup) Updates() []*sdcpb.Update

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL