Documentation
¶
Index ¶
- Constants
- Variables
- func IncreaseMinorVersion(v string) (string, error)
- func NewFilterBuilder() *filterBuilder
- func ParseVersion(v string) (*semver.Version, error)
- type Asset
- type DiscoveryError
- type DiscoveryRepository
- type Filter
- type GroupConfig
- type GroupField
- type GroupResult
- type InvalidError
- type Lineage
- type LineageDirection
- type LineageEdge
- type LineageGraph
- type LineageNotFoundError
- type LineageQuery
- type LineageRepository
- type NodeAttributes
- type NotFoundError
- type Probe
- type ProbesFilter
- type ProbesInfo
- type Repository
- type SearchConfig
- type SearchFilter
- type SearchFlags
- type SearchResult
- type Service
- func (s *Service) AddProbe(ctx context.Context, ns *namespace.Namespace, assetURN string, probe *Probe) error
- func (s *Service) DeleteAsset(ctx context.Context, ns *namespace.Namespace, id string) error
- func (s *Service) GetAllAssets(ctx context.Context, flt Filter, withTotal bool) ([]Asset, uint32, error)
- func (s *Service) GetAssetByID(ctx context.Context, id string) (ast Asset, err error)
- func (s *Service) GetAssetByVersion(ctx context.Context, id string, version string) (Asset, error)
- func (s *Service) GetAssetVersionHistory(ctx context.Context, flt Filter, id string) ([]Asset, error)
- func (s *Service) GetLineage(ctx context.Context, urn string, query LineageQuery) (Lineage, error)
- func (s *Service) GetTypes(ctx context.Context, flt Filter) (map[Type]int, error)
- func (s *Service) GroupAssets(ctx context.Context, cfg GroupConfig) ([]GroupResult, error)
- func (s *Service) SearchAssets(ctx context.Context, cfg SearchConfig) (results []SearchResult, err error)
- func (s *Service) SoftDeleteAsset(ctx context.Context, ns *namespace.Namespace, id string) error
- func (s *Service) SuggestAssets(ctx context.Context, cfg SearchConfig) (suggestions []string, err error)
- func (s *Service) UpsertAsset(ctx context.Context, ns *namespace.Namespace, ast *Asset, ...) (string, error)
- func (s *Service) UpsertAssetWithoutLineage(ctx context.Context, ns *namespace.Namespace, ast *Asset) (string, error)
- type Type
Constants ¶
const BaseVersion = "0.1"
Variables ¶
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") )
var AllSupportedTypes = []Type{ TypeTable, TypeJob, TypeDashboard, TypeTopic, TypeFeatureTable, TypeApplication, TypeModel, TypeQuery, TypeMetric, TypeExperiment, }
AllSupportedTypes holds a list of all supported types struct
var ErrAssetAlreadyDeleted = fmt.Errorf("asset already deleted")
Functions ¶
func IncreaseMinorVersion ¶
IncreaseMinorVersion bumps up the minor version +0.1
func NewFilterBuilder ¶
func NewFilterBuilder() *filterBuilder
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"`
IsDeleted bool `json:"is_deleted" diff:"is_deleted"`
CreatedAt time.Time `json:"created_at" diff:"-"`
UpdatedAt time.Time `json:"updated_at" diff:"-"`
RefreshedAt *time.Time `json:"refreshed_at,omitempty" 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
type DiscoveryError ¶
type DiscoveryError struct {
Err error
}
func (DiscoveryError) Error ¶
func (err DiscoveryError) Error() string
type DiscoveryRepository ¶
type DiscoveryRepository interface {
Upsert(ctx context.Context, ns *namespace.Namespace, ast *Asset) error
DeleteByID(ctx context.Context, ns *namespace.Namespace, assetID string) error
DeleteByURN(ctx context.Context, ns *namespace.Namespace, assetURN string) error
SoftDeleteByURN(ctx context.Context, ns *namespace.Namespace, assetURN string) error
Search(ctx context.Context, cfg SearchConfig) (results []SearchResult, err error)
Suggest(ctx context.Context, cfg SearchConfig) (suggestions []string, err error)
GroupAssets(ctx context.Context, cfg GroupConfig) ([]GroupResult, error)
}
type Filter ¶
type GroupConfig ¶ added in v0.7.0
type GroupConfig struct {
GroupBy []string
Filters SearchFilter
IncludeFields []string
Size int
Namespace *namespace.Namespace
}
GroupConfig represents configuration for grouping assets
type GroupField ¶ added in v0.7.0
GroupField represents a key-value pair identifying a group
type GroupResult ¶ added in v0.7.0
type GroupResult struct {
Fields []GroupField
Assets []Asset
}
GroupResult represents a single group of assets
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 LineageGraph ¶
type LineageGraph []LineageEdge
type LineageNotFoundError ¶
type LineageNotFoundError struct {
URN string
}
func (LineageNotFoundError) Error ¶
func (err LineageNotFoundError) Error() string
type LineageQuery ¶
type LineageQuery struct {
Level int
Direction LineageDirection
WithAttributes bool
IncludeDeleted bool
}
type LineageRepository ¶
type LineageRepository interface {
GetGraph(ctx context.Context, urn string, query LineageQuery) (LineageGraph, error)
Upsert(ctx context.Context, ns *namespace.Namespace, urn string, upstreams, downstreams []string) error
DeleteByURN(ctx context.Context, urn string) error
DeleteByURNs(ctx context.Context, urns []string) error
}
type NodeAttributes ¶
type NodeAttributes struct {
Probes ProbesInfo `json:"probes"`
}
type NotFoundError ¶
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 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, ns *namespace.Namespace, ast *Asset) (string, error)
DeleteByID(ctx context.Context, id string) error
DeleteByURN(ctx context.Context, urn string) error
SoftDeleteByID(ctx context.Context, id string) (string, error)
SoftDeleteByURN(ctx context.Context, urn string) (string, error)
GetCountByIsDeleted(ctx context.Context, isDeleted bool) (int, error)
HardDeleteByURNs(ctx context.Context, urns []string) error
AddProbe(ctx context.Context, ns *namespace.Namespace, 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
// Offset is the offset for search results, used for pagination
Offset 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
// IncludeFields specifies which fields to include in search results
IncludeFields []string
// Flags contains optional search flags
Flags SearchFlags
// Namespace under which assets are partitioned. *Required*
Namespace *namespace.Namespace `validate:"required"`
}
SearchConfig represents a search query along with any corresponding filter(s)
func (SearchConfig) Validate ¶
func (s SearchConfig) Validate() error
type SearchFilter ¶
SearchFilter is a filter intended to be used as a search criteria for operations involving asset search
type SearchFlags ¶ added in v0.7.0
SearchFlags contains flags that modify search behavior
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) DeleteAsset ¶
func (*Service) GetAllAssets ¶
func (*Service) GetAssetByID ¶
func (*Service) GetAssetByVersion ¶
func (*Service) GetAssetVersionHistory ¶
func (*Service) GetLineage ¶
func (*Service) GroupAssets ¶ added in v0.7.0
func (s *Service) GroupAssets(ctx context.Context, cfg GroupConfig) ([]GroupResult, error)
func (*Service) SearchAssets ¶
func (s *Service) SearchAssets(ctx context.Context, cfg SearchConfig) (results []SearchResult, err error)
func (*Service) SoftDeleteAsset ¶ added in v0.7.0
SoftDeleteAsset marks an asset as deleted without removing it
func (*Service) SuggestAssets ¶
func (*Service) UpsertAsset ¶
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" TypeQuery Type = "query" TypeMetric Type = "metric" TypeExperiment Type = "experiment" )