asset

package
v0.5.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const BaseVersion = "0.1"

Variables

View Source
var (
	ErrEmptyID     = errors.New("asset does not have ID")
	ErrEmptyURN    = errors.New("asset does not have URN")
	ErrUnknownType = errors.New("unknown type")
	ErrNilAsset    = errors.New("nil asset")
)

AllSupportedTypes holds a list of all supported types struct

Functions

func IncreaseMinorVersion

func IncreaseMinorVersion(v string) (string, error)

IncreaseMinorVersion bumps up the minor version +0.1

func NewFilterBuilder

func NewFilterBuilder() *filterBuilder

func ParseVersion

func ParseVersion(v string) (*semver.Version, error)

ParseVersion returns error if version string is not in MAJOR.MINOR format

Types

type Asset

type Asset struct {
	ID          string                 `json:"id" diff:"-"`
	URN         string                 `json:"urn" diff:"-"`
	Type        Type                   `json:"type" diff:"-"`
	Service     string                 `json:"service" diff:"-"`
	Name        string                 `json:"name" diff:"name"`
	Description string                 `json:"description" diff:"description"`
	Data        map[string]interface{} `json:"data" diff:"data"`
	URL         string                 `json:"url" diff:"url"`
	Labels      map[string]string      `json:"labels" diff:"labels"`
	Owners      []user.User            `json:"owners,omitempty" diff:"owners"`
	CreatedAt   time.Time              `json:"created_at" diff:"-"`
	UpdatedAt   time.Time              `json:"updated_at" diff:"-"`
	Version     string                 `json:"version" diff:"-"`
	UpdatedBy   user.User              `json:"updated_by" diff:"-"`
	Changelog   diff.Changelog         `json:"changelog,omitempty" diff:"-"`
	Probes      []Probe                `json:"probes,omitempty"`
}

Asset is a model that wraps arbitrary data with Compass' context

func (*Asset) Diff

func (a *Asset) Diff(otherAsset *Asset) (diff.Changelog, error)

Diff returns nil changelog with nil error if equal returns wrapped r3labs/diff Changelog struct with nil error if not equal

func (*Asset) Patch

func (a *Asset) Patch(patchData map[string]interface{})

Patch appends asset with data from map. It mutates the asset itself. It is using json annotation of the struct to patch the correct keys

type DiscoveryError

type DiscoveryError struct {
	Err error
}

func (DiscoveryError) Error

func (err DiscoveryError) Error() string

type DiscoveryRepository

type DiscoveryRepository interface {
	Upsert(context.Context, Asset) error
	DeleteByID(ctx context.Context, assetID string) error
	DeleteByURN(ctx context.Context, assetURN string) error
	Search(ctx context.Context, cfg SearchConfig) (results []SearchResult, err error)
	Suggest(ctx context.Context, cfg SearchConfig) (suggestions []string, err error)
}

type Filter

type Filter struct {
	Types         []Type
	Services      []string
	Size          int
	Offset        int
	SortBy        string `validate:"omitempty,oneof=name type service created_at updated_at"`
	SortDirection string `validate:"omitempty,oneof=asc desc"`
	QueryFields   []string
	Query         string
	Data          map[string][]string
}

func (*Filter) Validate

func (f *Filter) Validate() error

type InvalidError

type InvalidError struct {
	AssetID string
}

func (InvalidError) Error

func (err InvalidError) Error() string

type Lineage

type Lineage struct {
	Edges     []LineageEdge             `json:"edges"`
	NodeAttrs map[string]NodeAttributes `json:"node_attrs"`
}

type LineageDirection

type LineageDirection string
const (
	LineageDirectionUpstream   LineageDirection = "upstream"
	LineageDirectionDownstream LineageDirection = "downstream"
)

func (LineageDirection) IsValid

func (dir LineageDirection) IsValid() bool

type LineageEdge

type LineageEdge struct {
	// Source represents source's node ID
	Source string `json:"source"`

	// Target represents target's node ID
	Target string `json:"target"`

	// Prop is a map containing extra information about the edge
	Prop map[string]interface{} `json:"prop"`
}

type LineageGraph

type LineageGraph []LineageEdge

type LineageQuery

type LineageQuery struct {
	Level     int
	Direction LineageDirection
}

type LineageRepository

type LineageRepository interface {
	GetGraph(ctx context.Context, urn string, query LineageQuery) (LineageGraph, error)
	Upsert(ctx context.Context, urn string, upstreams, downstreams []string) error
}

type NodeAttributes

type NodeAttributes struct {
	Probes ProbesInfo `json:"probes"`
}

type NotFoundError

type NotFoundError struct {
	AssetID string
	URN     string
}

func (NotFoundError) Error

func (err NotFoundError) Error() string

type Probe

type Probe struct {
	ID           string                 `json:"id"`
	AssetURN     string                 `json:"asset_urn"`
	Status       string                 `json:"status"`
	StatusReason string                 `json:"status_reason"`
	Metadata     map[string]interface{} `json:"metadata"`
	Timestamp    time.Time              `json:"timestamp"`
	CreatedAt    time.Time              `json:"created_at"`
}

Probe represents a single asset's probe

type ProbesFilter

type ProbesFilter struct {
	AssetURNs []string
	MaxRows   int
	NewerThan time.Time
	OlderThan time.Time
}

type ProbesInfo

type ProbesInfo struct {
	Latest Probe `json:"latest"`
}

type Repository

type Repository interface {
	GetAll(context.Context, Filter) ([]Asset, error)
	GetCount(context.Context, Filter) (int, error)
	GetByID(ctx context.Context, id string) (Asset, error)
	GetByURN(ctx context.Context, urn string) (Asset, error)
	GetVersionHistory(ctx context.Context, flt Filter, id string) ([]Asset, error)
	GetByVersionWithID(ctx context.Context, id string, version string) (Asset, error)
	GetByVersionWithURN(ctx context.Context, urn string, version string) (Asset, error)
	GetTypes(ctx context.Context, flt Filter) (map[Type]int, error)
	Upsert(ctx context.Context, ast *Asset) (string, error)
	DeleteByID(ctx context.Context, id string) error
	DeleteByURN(ctx context.Context, urn string) error
	AddProbe(ctx context.Context, assetURN string, probe *Probe) error
	GetProbes(ctx context.Context, assetURN string) ([]Probe, error)
	GetProbesWithFilter(ctx context.Context, flt ProbesFilter) (map[string][]Probe, error)
}

type SearchConfig

type SearchConfig struct {
	// Text to search for
	Text string

	// Filters specifies document level values to look for.
	// Multiple values can be specified for a single key
	Filters SearchFilter

	// Number of relevant results to return
	MaxResults int

	// RankBy is a param to rank based on a specific parameter
	RankBy string

	// Queries is a param to search a resource based on asset's fields
	Queries map[string]string
}

SearchConfig represents a search query along with any corresponding filter(s)

type SearchFilter

type SearchFilter = map[string][]string

SearchFilter is a filter intended to be used as a search criteria for operations involving asset search

type SearchResult

type SearchResult struct {
	ID          string                 `json:"id"`
	URN         string                 `json:"urn"`
	Title       string                 `json:"title"`
	Type        string                 `json:"type"`
	Service     string                 `json:"service"`
	Description string                 `json:"description"`
	Labels      map[string]string      `json:"labels"`
	Data        map[string]interface{} `json:"data"`
}

SearchResult represents an item/result in a list of search results

func (SearchResult) ToAsset

func (sr SearchResult) ToAsset() Asset

ToAsset returns search result as asset

type Service

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

func NewService

func NewService(assetRepository Repository, discoveryRepository DiscoveryRepository, lineageRepository LineageRepository) *Service

func (*Service) AddProbe

func (s *Service) AddProbe(ctx context.Context, assetURN string, probe *Probe) error

func (*Service) DeleteAsset

func (s *Service) DeleteAsset(ctx context.Context, id string) error

func (*Service) GetAllAssets

func (s *Service) GetAllAssets(ctx context.Context, flt Filter, withTotal bool) ([]Asset, uint32, error)

func (*Service) GetAssetByID

func (s *Service) GetAssetByID(ctx context.Context, id string) (ast Asset, err error)

func (*Service) GetAssetByVersion

func (s *Service) GetAssetByVersion(ctx context.Context, id string, version string) (Asset, error)

func (*Service) GetAssetVersionHistory

func (s *Service) GetAssetVersionHistory(ctx context.Context, flt Filter, id string) ([]Asset, error)

func (*Service) GetLineage

func (s *Service) GetLineage(ctx context.Context, urn string, query LineageQuery) (Lineage, error)

func (*Service) GetTypes

func (s *Service) GetTypes(ctx context.Context, flt Filter) (map[Type]int, error)

func (*Service) SearchAssets

func (s *Service) SearchAssets(ctx context.Context, cfg SearchConfig) (results []SearchResult, err error)

func (*Service) SuggestAssets

func (s *Service) SuggestAssets(ctx context.Context, cfg SearchConfig) (suggestions []string, err error)

func (*Service) UpsertAsset

func (s *Service) UpsertAsset(ctx context.Context, ast *Asset, upstreams, downstreams []string) (string, error)

func (*Service) UpsertAssetWithoutLineage

func (s *Service) UpsertAssetWithoutLineage(ctx context.Context, ast *Asset) (string, error)

type Type

type Type string

Type specifies a supported type name

const (
	TypeTable        Type = "table"
	TypeJob          Type = "job"
	TypeDashboard    Type = "dashboard"
	TypeTopic        Type = "topic"
	TypeFeatureTable Type = "feature_table"
	TypeApplication  Type = "application"
	TypeModel        Type = "model"
)

func (Type) IsValid

func (t Type) IsValid() bool

IsValid will validate whether the typename is valid or not

func (Type) String

func (t Type) String() string

String cast Type to string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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