github.com/yanndegat/hiera@v0.6.8/api/session.go (about)

     1  package api
     2  
     3  import (
     4  	"context"
     5  	"sync"
     6  
     7  	"github.com/lyraproj/dgo/dgo"
     8  	"github.com/lyraproj/dgo/streamer"
     9  	"github.com/lyraproj/hierasdk/hiera"
    10  )
    11  
    12  // A Session determines the life cycle of cached values during a Hiera session.
    13  type Session interface {
    14  	context.Context
    15  
    16  	// AliasMap is the map that manages all type aliases used during the session.
    17  	AliasMap() dgo.AliasMap
    18  
    19  	// Dialect determines what language to use when parsing types and serializing/deserializing
    20  	// rich data.
    21  	Dialect() streamer.Dialect
    22  
    23  	// KillPlugins ensures that all external plugin processes that were started by this session are killed.
    24  	KillPlugins()
    25  
    26  	// LoadFunction loads the lookup function defined in the given hierarchy entry and returns
    27  	// it together with a flag indicating if the load was a success
    28  	LoadFunction(he Entry) (dgo.Function, bool)
    29  
    30  	// Invocation creates a new invocation for this session
    31  	Invocation(scope interface{}, explainer Explainer) Invocation
    32  
    33  	// SessionOptions returns the session specific options
    34  	SessionOptions() dgo.Map
    35  
    36  	// Loader returns the session specific loader
    37  	Loader() dgo.Loader
    38  
    39  	// Scope returns the session's scope
    40  	Scope() dgo.Keyed
    41  
    42  	// SharedCache returns the cache that is shared
    43  	SharedCache() *sync.Map
    44  
    45  	// TopProvider returns the lookup function that defines the hierarchy
    46  	TopProvider() hiera.LookupKey
    47  
    48  	// TopProviderCache returns the shared provider cache used by all lookups
    49  	TopProviderCache() *sync.Map
    50  
    51  	// Get returns a session variable, or nil if no such variable exists. Session variables
    52  	// are used internally by Hiera and should not be confused with Scope variables.
    53  	Get(key string) interface{}
    54  }