tolerance

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GitAuthPrivateKey

func GitAuthPrivateKey(pem []byte) (protocol.GitAuth, error)

GitAuthPrivateKey creates authentication configuration using a private, pem encoded key. This can be used for initialising a GitRepository via NewGitRepository

Types

type CompactSpec

type CompactSpec struct {
	TableID      string
	TableMetrics []*MetricSpec
	Fields       []*Field
}

CompactSpec compact tolerance spec is structured json/yaml schema with less redundant fields

type CompactSpecParser

type CompactSpecParser struct {
}

CompactSpecParser is parser for CompactSpec

func (*CompactSpecParser) Parse

func (s *CompactSpecParser) Parse(content []byte) (*protocol.ToleranceSpec, error)

func (*CompactSpecParser) Serialise

func (s *CompactSpecParser) Serialise(toleranceSpec *protocol.ToleranceSpec) (content []byte, err error)

type DefaultFileStoreFactory

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

DefaultFileStoreFactory to create specific FileBasedToleranceRepository from URL path

func NewFileStoreFactory

func NewFileStoreFactory(client stiface.Client) *DefaultFileStoreFactory

NewFileStoreFactory to create FileBasedToleranceRepository based on URL path

func (*DefaultFileStoreFactory) Create

Create to create FileBasedToleranceRepository based on URL path

type DefaultPathResolver

type DefaultPathResolver struct {
}

DefaultPathResolver to get file path with {project-id}.{dataset}.{tablename}.yaml format this is the default setting that applied without multi tenancy enabled

func (*DefaultPathResolver) GetPath

func (d *DefaultPathResolver) GetPath(urn string) (string, error)

func (*DefaultPathResolver) GetURN

func (d *DefaultPathResolver) GetURN(filePath string) (string, error)

type EntityBasedStore

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

func NewEntityBasedStore

func NewEntityBasedStore(entity *protocol.Entity, source protocol.ToleranceStore) *EntityBasedStore

func (*EntityBasedStore) Create

func (e *EntityBasedStore) Create(spec *protocol.ToleranceSpec) error

func (*EntityBasedStore) Delete

func (e *EntityBasedStore) Delete(tableID string) error

func (*EntityBasedStore) GetAll

func (e *EntityBasedStore) GetAll() ([]*protocol.ToleranceSpec, error)

func (*EntityBasedStore) GetByProjectID

func (e *EntityBasedStore) GetByProjectID(projectID string) ([]*protocol.ToleranceSpec, error)

func (*EntityBasedStore) GetByTableID

func (e *EntityBasedStore) GetByTableID(tableID string) (*protocol.ToleranceSpec, error)

func (*EntityBasedStore) GetResourceNames

func (e *EntityBasedStore) GetResourceNames() ([]string, error)

type Factory

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

func NewFactory

func NewFactory(resolverFactory *PathResolverFactory, fileStoreFactory protocol.FileStoreFactory) *Factory

NewFactory create Factory of protocol.ToleranceStore

func (*Factory) Create

func (t *Factory) Create(URL string, multiTenancyEnabled bool) (protocol.ToleranceStore, error)

Create multiple implementation of protocol.ToleranceStore this Method only support protocol.MultiTenancy and protocol.Default protocol.PathType directory structure of protocol.PathResolver

func (*Factory) CreateWithOptions

func (t *Factory) CreateWithOptions(store protocol.FileStore, pathType protocol.PathType) (protocol.ToleranceStore, error)

CreateWithOptions intended to create more customised version of protocol.ToleranceStore this support custom protocol.FileStore and all of protocol.PathType including protocol.MultiTenancy, protocol.Default and protocol.Git

type Field

type Field struct {
	FieldID      string
	FieldMetrics []*MetricSpec
}

type FileBasedStore

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

FileBasedStore is storage of tolerance spec that use file as storage

func NewFileBasedStore

func NewFileBasedStore(toleranceRepo protocol.FileStore, pathResolver protocol.PathResolver, parser Parser) *FileBasedStore

NewFileBasedStore is constructor

func (*FileBasedStore) Create

func (f *FileBasedStore) Create(spec *protocol.ToleranceSpec) error

func (*FileBasedStore) Delete

func (f *FileBasedStore) Delete(tableID string) error

func (*FileBasedStore) GetAll

func (f *FileBasedStore) GetAll() ([]*protocol.ToleranceSpec, error)

func (*FileBasedStore) GetByProjectID

func (f *FileBasedStore) GetByProjectID(projectID string) ([]*protocol.ToleranceSpec, error)

func (*FileBasedStore) GetByTableID

func (f *FileBasedStore) GetByTableID(tableID string) (*protocol.ToleranceSpec, error)

GetByTableID to get tolerances of a table using table ID

func (*FileBasedStore) GetResourceNames

func (f *FileBasedStore) GetResourceNames() ([]string, error)

type FlatSpec

type FlatSpec []*Tolerance

FlatSpec is predator tolerance spec presented as list json/yaml structure

type FlatSpecParser

type FlatSpecParser struct {
}

FlatSpecParser is parser for FlatSpec format

func (*FlatSpecParser) Parse

func (s *FlatSpecParser) Parse(content []byte) (*protocol.ToleranceSpec, error)

func (*FlatSpecParser) Serialise

func (s *FlatSpecParser) Serialise(tolerances *protocol.ToleranceSpec) (content []byte, err error)

type GcsFileStorage

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

GcsFileStorage is FileStore that use google cloud storage every file placed under basePath directory please always resolve filepath with basePath to get the fullPath

func NewGcsRepository

func NewGcsRepository(client stiface.Client, gcsPath string) *GcsFileStorage

NewGcsRepository to create GcsFileStorage

func (*GcsFileStorage) Create

func (r *GcsFileStorage) Create(file *protocol.File) (err error)

func (*GcsFileStorage) Delete

func (r *GcsFileStorage) Delete(filePath string) error

func (*GcsFileStorage) Get

func (r *GcsFileStorage) Get(filePath string) (file *protocol.File, err error)

GetFile to read a file from google cloud storage

func (*GcsFileStorage) GetAll

func (r *GcsFileStorage) GetAll() ([]*protocol.File, error)

func (*GcsFileStorage) GetPaths

func (r *GcsFileStorage) GetPaths() ([]string, error)

GetPaths get all files path only support files that has .yaml extension

type GitPathResolver

type GitPathResolver struct {
}

GitPathResolver is path resolver for tolerances specs in git repository the path format is {project-id}/{dataset}/{tablename}.yaml

func (*GitPathResolver) GetPath

func (g *GitPathResolver) GetPath(urn string) (string, error)

func (*GitPathResolver) GetURN

func (g *GitPathResolver) GetURN(filePath string) (string, error)

type GitRepository

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

GitRepository provides a FS like access to remote git repositories It clones the repository locally, and provides a FS interface over the contents.

func (*GitRepository) Checkout

func (repo *GitRepository) Checkout(commit string) (protocol.FileStore, error)

Checkout returns a Git FileSystem at a certain commit Remember to call Close on the returned FileSystem, otherwise the checked out repository on disk will not be not be deleted if commit is empty, checksout master

type GitRepositoryFactory

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

GitRepositoryFactory creator of GitRepository

func NewGitRepositoryFactory

func NewGitRepositoryFactory(auth protocol.GitAuth) *GitRepositoryFactory

func (*GitRepositoryFactory) Create

Create create GitRepository

func (*GitRepositoryFactory) CreateWithPrefix

func (g *GitRepositoryFactory) CreateWithPrefix(url string, pathPrefix string) protocol.GitRepository

type LocalFileStorage

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

LocalFileStorage is a FileBasedToleranceRepository that use local file as tolerance every files in this storage is located under baseDir always resolve the path with base dir for any operation

func NewLocalRepository

func NewLocalRepository(baseDir string) *LocalFileStorage

NewLocalRepository is constructor of LocalFileStorage

func (*LocalFileStorage) Create

func (l *LocalFileStorage) Create(file *protocol.File) error

func (*LocalFileStorage) Delete

func (l *LocalFileStorage) Delete(filePath string) error

func (*LocalFileStorage) Get

func (l *LocalFileStorage) Get(filePath string) (*protocol.File, error)

Get to read file from local directory

func (*LocalFileStorage) GetAll

func (l *LocalFileStorage) GetAll() ([]*protocol.File, error)

GetAll read all files that managed by storage by convention only file with .yaml files will be returned

func (*LocalFileStorage) GetPaths

func (l *LocalFileStorage) GetPaths() ([]string, error)

type Metadata

type Metadata struct {
	//UniqueFields are metadata that required to profile unique count
	UniqueFields []string
}

type MetricSpec

type MetricSpec struct {
	MetricName metric.Type
	Condition  string
	Metadata   map[string]interface{}
	Tolerance  RulesMap
}

type MultiTenancyPathResolver

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

MultiTenancyPathResolver is path resolver for tolerances spec in multi tenancy configuration the path format is {environment}/{entity}/{project-id}/{dataset}/{tablename}.yaml

func (*MultiTenancyPathResolver) GetPath

func (p *MultiTenancyPathResolver) GetPath(urn string) (string, error)

func (*MultiTenancyPathResolver) GetURN

func (p *MultiTenancyPathResolver) GetURN(filePath string) (string, error)

type Parser

type Parser interface {
	Parse(content []byte) (*protocol.ToleranceSpec, error)
	Serialise(*protocol.ToleranceSpec) ([]byte, error)
}

Parser is parser and serializer of tolerance spec

type PathResolverFactory

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

func NewPathResolverFactory

func NewPathResolverFactory(entityStore protocol.EntityStore) *PathResolverFactory

NewPathResolverFactory create PathResolverFactory

func (*PathResolverFactory) CreateResolver

func (p *PathResolverFactory) CreateResolver(pathType protocol.PathType) protocol.PathResolver

CreateResolver create PathResolver

type RulesMap

type RulesMap map[string]float64

RulesMap tolerance rules as map

func NewRulesMap

func NewRulesMap(rules []protocol.ToleranceRule) RulesMap

func (RulesMap) ToArray

func (r RulesMap) ToArray() []protocol.ToleranceRule

type SmartParser

type SmartParser struct {
}

SmartParser parser that automatically Parse yaml that using either CompactSpec or FlatSpec

func NewSmartParser

func NewSmartParser() *SmartParser

func (*SmartParser) Parse

func (s *SmartParser) Parse(content []byte) (*protocol.ToleranceSpec, error)

func (*SmartParser) Serialise

func (s *SmartParser) Serialise(tolerances *protocol.ToleranceSpec) ([]byte, error)

type SpecValidator

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

func NewSpecValidator

func NewSpecValidator(metadataStore protocol.MetadataStore) *SpecValidator

NewSpecValidator create spec validator

func (*SpecValidator) Validate

func (d *SpecValidator) Validate(spec *protocol.ToleranceSpec) error

type Tolerance

type Tolerance struct {
	ID             string
	TableID        string
	FieldID        string
	MetricName     metric.Type
	ToleranceRules RulesMap
	CreatedAt      time.Time
	UpdatedAt      time.Time
}

Tolerance is format of tolerance configuration

func (*Tolerance) ToTolerance

func (t *Tolerance) ToTolerance() *protocol.Tolerance

type Upload

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

func (*Upload) Run

func (u *Upload) Run() (i interface{}, err error)

Run get entity information

type UploadFactory

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

func NewUploadFactory

func NewUploadFactory(multiTenancyEnabled bool,
	entityStore protocol.EntityStore,
	sourceFactory protocol.ToleranceStoreFactory,
	destination protocol.ToleranceStore,
	gitRepositoryFactory protocol.GitRepositoryFactory,
	statsFactory stats.ClientBuilder,
	metadataStore protocol.MetadataStore) *UploadFactory

NewUploadFactory create UploadFactory

func (*UploadFactory) Create

func (u *UploadFactory) Create(gitRepo *protocol.GitInfo) (protocol.Task, error)

Create create protocol.Task

Jump to

Keyboard shortcuts

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