Documentation ¶
Index ¶
- func BuildNativeSystemEnvOverrides(envOverrides ...EnvOverride) func(config *Config) error
- type BatchInfo
- type Config
- type DataLayerService
- type DataLayerServiceFactory
- type Dataset
- type DatasetDefinition
- type DatasetDescription
- type DatasetWriter
- type EntityIterator
- type EntityToItemPropertyMapping
- type EnvOverride
- type IncomingMappingConfig
- type Item
- type ItemToEntityPropertyMapping
- type LayerError
- type LayerErrorType
- type LayerServiceConfig
- type Logger
- type Mapper
- func (mapper *Mapper) MapEntityToItem(entity *egdm.Entity, item Item) error
- func (mapper *Mapper) MapItemToEntity(item Item, entity *egdm.Entity) error
- func (mapper *Mapper) WithEntityToItemTransform(transform func(entity *egdm.Entity, item Item) error) *Mapper
- func (mapper *Mapper) WithItemToEntityTransform(transform func(item Item, entity *egdm.Entity) error) *Mapper
- type Metrics
- type NativeSystemConfig
- type OutgoingMappingConfig
- type PropertyConstructor
- type ServiceRunner
- func (serviceRunner *ServiceRunner) Start() error
- func (serviceRunner *ServiceRunner) StartAndWait()
- func (serviceRunner *ServiceRunner) Stop() error
- func (serviceRunner *ServiceRunner) WithConfigLocation(configLocation string) *ServiceRunner
- func (serviceRunner *ServiceRunner) WithEnrichConfig(enrichConfig func(config *Config) error) *ServiceRunner
- type StatsdMetrics
- type Stoppable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildNativeSystemEnvOverrides ¶ added in v0.2.0
func BuildNativeSystemEnvOverrides(envOverrides ...EnvOverride) func(config *Config) error
BuildNativeSystemEnvOverrides can be plugged into `WithEnrichConfig`
it takes a variadic parameter list, each of which declares an environment variable that the layer will try to look up at start, and add to system_config.
Types ¶
type Config ¶
type Config struct { ConfigPath string // set by service runner NativeSystemConfig NativeSystemConfig `json:"system_config"` LayerServiceConfig *LayerServiceConfig `json:"layer_config"` DatasetDefinitions []*DatasetDefinition `json:"dataset_definitions"` }
func (*Config) GetDatasetDefinition ¶
func (c *Config) GetDatasetDefinition(dataset string) *DatasetDefinition
type DataLayerService ¶
type DataLayerService interface { Stoppable UpdateConfiguration(config *Config) LayerError Dataset(dataset string) (Dataset, LayerError) DatasetDescriptions() []*DatasetDescription }
type DataLayerServiceFactory ¶
type DataLayerServiceFactory interface {
Build(config *Config, logger Logger, metrics Metrics) (DataLayerService, error)
}
type Dataset ¶
type Dataset interface { MetaData() map[string]any Name() string // FullSync produces a DatasetWriter, which depending on fullsync state in batchInfo // starts, continues or ends a fullsync operation spanning over multiple requests. // Layers should also remove stale entities after a fullsync finishes. FullSync(ctx context.Context, batchInfo BatchInfo) (DatasetWriter, LayerError) // Incremental produces a DatasetWriter, which appends changes to the dataset when // written to. Incremental(ctx context.Context) (DatasetWriter, LayerError) // Changes retrieves changes in a dataset. Use since parameter to // continue consumption of changes in succesive requests Changes(since string, limit int, latestOnly bool) (EntityIterator, LayerError) // Entities retrieves all current entities in a dataset. Use from+limit parameters // to page through large datasets in batches. Entities(from string, limit int) (EntityIterator, LayerError) }
type DatasetDefinition ¶
type DatasetDefinition struct { SourceConfig map[string]any `json:"source_config"` IncomingMappingConfig *IncomingMappingConfig `json:"incoming_mapping_config"` OutgoingMappingConfig *OutgoingMappingConfig `json:"outgoing_mapping_config"` DatasetName string `json:"name"` }
type DatasetDescription ¶ added in v0.1.1
type DatasetWriter ¶
type DatasetWriter interface { Write(entity *egdm.Entity) LayerError Close() LayerError }
type EntityIterator ¶
type EntityIterator interface { // Context returns the context for the current iteration. This context // contains namespace mappings for the whole dataset as per UDA spec Context() *egdm.Context // Next moves the iterator to the next entity. returns nil when exhausted Next() (*egdm.Entity, LayerError) // Token returns the continuation token for the next iteration, if applicable Token() (*egdm.Continuation, LayerError) // Close releases underlying data source objects Close() LayerError }
type EntityToItemPropertyMapping ¶
type EntityToItemPropertyMapping struct { Custom map[string]any EntityProperty string `json:"entity_property"` Property string `json:"property"` Datatype string `json:"datatype"` DefaultValue string `json:"default_value"` StripReferencePrefix bool `json:"strip_ref_prefix"` Required bool `json:"required"` IsIdentity bool `json:"is_identity"` IsReference bool `json:"is_reference"` IsDeleted bool `json:"is_deleted"` IsRecorded bool `json:"is_recorded"` }
type EnvOverride ¶ added in v0.2.0
****************************************************************************
func Env ¶ added in v0.2.0
func Env(key string, specs ...any) EnvOverride
Env function to conveniently construct EnvOverride instances
type IncomingMappingConfig ¶
type IncomingMappingConfig struct { Custom map[string]any `json:"custom"` BaseURI string `json:"base_uri"` PropertyMappings []*EntityToItemPropertyMapping `json:"property_mappings"` MapNamed bool `json:"map_named"` }
type Item ¶
type Item interface { // GetValue returns the value of the property with the given name GetValue(name string) any // SetValue sets the value of the property with the given name SetValue(name string, value any) // NativeItem returns the underlying native item NativeItem() any // GetPropertyNames returns the names of all properties in the item GetPropertyNames() []string }
type ItemToEntityPropertyMapping ¶
type ItemToEntityPropertyMapping struct { DefaultValue any `json:"default_value"` Custom map[string]any EntityProperty string `json:"entity_property"` Property string `json:"property"` Datatype string `json:"datatype"` URIValuePattern string `json:"uri_value_pattern"` Required bool `json:"required"` IsIdentity bool `json:"is_identity"` IsReference bool `json:"is_reference"` IsDeleted bool `json:"is_deleted"` IsRecorded bool `json:"is_recorded"` }
type LayerError ¶
func Err ¶
func Err(err error, errType LayerErrorType) LayerError
func Errorf ¶
func Errorf(errType LayerErrorType, format string, args ...any) LayerError
type LayerErrorType ¶
type LayerErrorType int
const ( LayerErrorBadParameter LayerErrorType = iota LayerErrorInternal LayerNotSupported )
type LayerServiceConfig ¶
type LayerServiceConfig struct { Custom map[string]any `json:"custom"` ServiceName string `json:"service_name"` Port json.Number `json:"port"` ConfigRefreshInterval string `json:"config_refresh_interval"` LogLevel string `json:"log_level"` LogFormat string `json:"log_format"` StatsdAgentAddress string `json:"statsd_agent_address"` StatsdEnabled bool `json:"statsd_enabled"` }
type Mapper ¶
type Mapper struct {
// contains filtered or unexported fields
}
func NewMapper ¶
func NewMapper(logger Logger, incomingMappingConfig *IncomingMappingConfig, outgoingMappingConfig *OutgoingMappingConfig) *Mapper
func (*Mapper) MapEntityToItem ¶
func (*Mapper) MapItemToEntity ¶
func (*Mapper) WithEntityToItemTransform ¶
type Metrics ¶
type Metrics interface { Incr(s string, tags []string, i int) LayerError Timing(s string, timed time.Duration, tags []string, i int) LayerError Gauge(s string, f float64, tags []string, i int) LayerError }
type NativeSystemConfig ¶
type OutgoingMappingConfig ¶
type OutgoingMappingConfig struct { Custom map[string]any `json:"custom"` BaseURI string `json:"base_uri"` Constructions []*PropertyConstructor `json:"constructions"` PropertyMappings []*ItemToEntityPropertyMapping `json:"property_mappings"` MapAll bool `json:"map_all"` }
type PropertyConstructor ¶
type PropertyConstructor struct { PropertyName string `json:"property"` Operation string `json:"operation"` Arguments []string `json:"args"` }
the operations can be one of the following: concat, split, replace, trim, tolower, toupper, regex, slice
type ServiceRunner ¶
type ServiceRunner struct {
// contains filtered or unexported fields
}
func NewServiceRunner ¶
func NewServiceRunner(newLayerService func(config *Config, logger Logger, metrics Metrics) (DataLayerService, error)) *ServiceRunner
func (*ServiceRunner) Start ¶
func (serviceRunner *ServiceRunner) Start() error
func (*ServiceRunner) StartAndWait ¶
func (serviceRunner *ServiceRunner) StartAndWait()
func (*ServiceRunner) Stop ¶
func (serviceRunner *ServiceRunner) Stop() error
func (*ServiceRunner) WithConfigLocation ¶
func (serviceRunner *ServiceRunner) WithConfigLocation(configLocation string) *ServiceRunner
func (*ServiceRunner) WithEnrichConfig ¶
func (serviceRunner *ServiceRunner) WithEnrichConfig(enrichConfig func(config *Config) error) *ServiceRunner
type StatsdMetrics ¶
type StatsdMetrics struct {
// contains filtered or unexported fields
}
func (StatsdMetrics) Gauge ¶
func (sm StatsdMetrics) Gauge(name string, value float64, tags []string, rate int) LayerError
func (StatsdMetrics) Incr ¶
func (sm StatsdMetrics) Incr(name string, tags []string, rate int) LayerError
func (StatsdMetrics) Timing ¶
func (sm StatsdMetrics) Timing(name string, value time.Duration, tags []string, rate int) LayerError
Source Files ¶
Click to show internal directories.
Click to hide internal directories.