Documentation
¶
Index ¶
- Constants
- Variables
- func IncreaseMinorVersion(v string) (string, error)
- func NewFilterBuilder() *filterBuilder
- func ParseVersion(v string) (*semver.Version, error)
- func RegisterSupportedTypes(types ...Type) error
- type Asset
- type Config
- type DeleteAssetExpr
- type DeleteAssetsRequest
- type DiscoveryError
- type DiscoveryRepository
- type Filter
- type GroupConfig
- type GroupField
- type GroupResult
- type InvalidError
- type Lineage
- type LineageDirection
- type LineageEdge
- type LineageGraph
- 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, assetURN string, probe *Probe) error
- func (s *Service) DeleteAsset(ctx context.Context, id string) (err error)
- func (s *Service) DeleteAssets(ctx context.Context, request DeleteAssetsRequest) (affectedRows uint32, err error)
- func (s *Service) DeleteAssetsByServicesAndUpdatedAt(ctx context.Context, dryRun bool, services string, ...) (uint32, error)
- func (s *Service) GetAllAssets(ctx context.Context, flt Filter, withTotal bool) ([]Asset, uint32, error)
- func (s *Service) GetAssetByID(ctx context.Context, id string) (Asset, error)
- func (s *Service) GetAssetByIDWithoutProbes(ctx context.Context, id string) (Asset, error)
- func (s *Service) GetAssetByVersion(ctx context.Context, id, version string) (ast Asset, err 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) (results []GroupResult, err error)
- func (s *Service) SearchAssets(ctx context.Context, cfg SearchConfig) (results []SearchResult, err error)
- func (s *Service) SoftDeleteAsset(ctx context.Context, id, updatedBy string) (err error)
- func (s *Service) SoftDeleteAssets(ctx context.Context, request DeleteAssetsRequest, updatedBy string) (affectedRows uint32, err error)
- func (s *Service) SuggestAssets(ctx context.Context, cfg SearchConfig) (suggestions []string, err error)
- func (s *Service) SyncAssets(ctx context.Context, services []string) error
- func (s *Service) UpsertAsset(ctx context.Context, ast *Asset, upstreams, downstreams []string) (string, error)
- func (s *Service) UpsertAssetWithoutLineage(ctx context.Context, ast *Asset) (string, error)
- func (s *Service) UpsertPatchAsset(ctx context.Context, ast *Asset, upstreams, downstreams []string, ...) (string, error)
- func (s *Service) UpsertPatchAssetWithoutLineage(ctx context.Context, ast *Asset, patchData map[string]interface{}) (string, error)
- type ServiceDeps
- type SoftDeleteAssetParams
- type Type
- type Worker
Constants ¶
const AllServicesCleanupConfig = "all"
const BaseVersion = "0.1"
Variables ¶
var ( ErrEmptyID = errors.New("asset does not have ID") ErrProbeExists = errors.New("asset probe already exists") ErrEmptyURN = errors.New("asset does not have URN") ErrEmptyQuery = errors.New("query is empty") ErrEmptyServices = errors.New("services is empty") ErrUnknownType = errors.New("unknown type") ErrNilAsset = errors.New("nil asset") ErrURNExist = errors.New("urn asset is already exist") ErrAssetAlreadyDeleted = errors.New("asset already deleted") ErrExpiryThresholdTimeIsZero = errors.New("expiry threshold time is zero") )
Functions ¶
func IncreaseMinorVersion ¶
IncreaseMinorVersion bumps up the minor version +0.1
func NewFilterBuilder ¶
func NewFilterBuilder() *filterBuilder
func ParseVersion ¶
ParseVersion returns error if version string is not in MAJOR.MINOR format
func RegisterSupportedTypes ¶ added in v0.7.7
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:"-"` RefreshedAt *time.Time `json:"refreshed_at" diff:"-"` Version string `json:"version" diff:"-"` UpdatedBy user.User `json:"updated_by" diff:"-"` IsDeleted bool `json:"is_deleted" diff:"is_deleted"` Changelog diff.Changelog `json:"changelog,omitempty" diff:"-"` Probes []Probe `json:"probes,omitempty"` }
Asset is a model that wraps arbitrary data with Compass' context
type Config ¶ added in v0.7.9
type DeleteAssetExpr ¶ added in v0.7.8
func (DeleteAssetExpr) ToQuery ¶ added in v0.7.8
func (d DeleteAssetExpr) ToQuery() (string, error)
func (DeleteAssetExpr) Validate ¶ added in v0.7.8
func (d DeleteAssetExpr) Validate() error
type DeleteAssetsRequest ¶ added in v0.7.8
type DiscoveryError ¶
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 SoftDeleteByURN(ctx context.Context, params SoftDeleteAssetParams) error DeleteByQueryExpr(ctx context.Context, queryExpr queryexpr.ExprStr) error DeleteByIsDeletedAndServicesAndUpdatedAt(ctx context.Context, isDeleted bool, services []string, expiryThreshold time.Time) error SoftDeleteAssets(ctx context.Context, assets []Asset, doUpdateVersion bool) 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) (results []GroupResult, err error) SyncAssets(ctx context.Context, indexName string) (cleanup func() error, err error) }
type Filter ¶
type GroupConfig ¶ added in v0.5.4
type GroupConfig struct { // IncludedFields specifies the fields to return in response IncludedFields []string // GroupBy fields to group on GroupBy []string // Filters specifies document level values to look for. // Multiple values can be specified for a single key Filters SearchFilter // Number of documents you want in response Size int }
GroupConfig represents a group query along with any corresponding filter(s)
type GroupField ¶ added in v0.5.4
type GroupResult ¶ added in v0.5.4
type GroupResult struct { Fields []GroupField Assets []Asset }
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 LineageQuery ¶
type LineageQuery struct { Level int Direction LineageDirection WithAttributes bool }
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 DeleteByURN(ctx context.Context, urn string) error SoftDeleteByURN(ctx context.Context, urn string) error DeleteByURNs(ctx context.Context, urns []string) error SoftDeleteByURNs(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) GetCountByQueryExpr(ctx context.Context, queryExpr queryexpr.ExprStr) (uint32, error) GetCountByIsDeletedAndServicesAndUpdatedAt(ctx context.Context, isDeleted bool, services []string, thresholdTime time.Time) (uint32, 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, version string) (Asset, error) GetByVersionWithURN(ctx context.Context, urn, version string) (Asset, error) GetTypes(ctx context.Context, flt Filter) (map[Type]int, error) Upsert(ctx context.Context, ast *Asset) (*Asset, error) UpsertPatch(ctx context.Context, ast *Asset, patchData map[string]interface{}) (*Asset, error) DeleteByID(ctx context.Context, id string) (string, error) DeleteByURN(ctx context.Context, urn string) error SoftDeleteByID(ctx context.Context, executedAt time.Time, id, updatedByID string) (string, string, error) SoftDeleteByURN(ctx context.Context, executedAt time.Time, urn, updatedByID string) (string, error) DeleteByQueryExpr(ctx context.Context, queryExpr queryexpr.ExprStr) ([]string, error) DeleteByIsDeletedAndServicesAndUpdatedAt(ctx context.Context, isDeleted bool, services []string, thresholdTime time.Time) (urns []string, err error) SoftDeleteByQueryExpr(ctx context.Context, executedAt time.Time, updatedByID string, queryExpr queryexpr.ExprStr) ([]Asset, 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 // Flags flags to control the search behavior (e.g. column level search, disable fuzzy, etc) Flags SearchFlags // Offset parameter defines the offset from the first result you want to fetch // Note that MaxResults + Offset can not be more than the `index.max_result_window` index setting in ES cluster, which defaults to 10,000 Offset int // IncludeFields specifies the fields to return in response IncludeFields []string }
SearchConfig represents a search query along with any corresponding filter(s)
type SearchFilter ¶
SearchFilter is a filter intended to be used as a search criteria for operations involving asset search
type SearchFlags ¶ added in v0.5.5
type SearchFlags struct { EnableHighlight bool // DisableFuzzy disables fuzziness on search DisableFuzzy bool IsColumnSearch bool }
SearchFlags is intended to be used as flags to control the search behavior (e.g. column level search, disable fuzzy, enable highlight etc) for operations involving asset search
type SearchResult ¶
type SearchResult struct { ID string URN string Title string Type string Service string Description string Labels map[string]string Data map[string]interface{} IsDeleted bool }
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(deps ServiceDeps) (service *Service, cancel func())
func (*Service) DeleteAsset ¶
DeleteAsset is hard-deletion that can accept ID or URN of asset
func (*Service) DeleteAssets ¶ added in v0.7.8
func (*Service) DeleteAssetsByServicesAndUpdatedAt ¶ added in v0.9.1
func (*Service) GetAllAssets ¶
func (*Service) GetAssetByID ¶
func (*Service) GetAssetByIDWithoutProbes ¶ added in v0.6.1
func (*Service) GetAssetByVersion ¶
func (*Service) GetAssetVersionHistory ¶
func (*Service) GetLineage ¶
func (*Service) GroupAssets ¶ added in v0.5.4
func (s *Service) GroupAssets(ctx context.Context, cfg GroupConfig) (results []GroupResult, err error)
func (*Service) SearchAssets ¶
func (s *Service) SearchAssets(ctx context.Context, cfg SearchConfig) (results []SearchResult, err error)
func (*Service) SoftDeleteAsset ¶ added in v0.9.0
SoftDeleteAsset is soft-deletion that can accept ID or URN of asset
func (*Service) SoftDeleteAssets ¶ added in v0.9.0
func (*Service) SuggestAssets ¶
func (*Service) SyncAssets ¶ added in v0.7.0
func (*Service) UpsertAsset ¶
func (*Service) UpsertAssetWithoutLineage ¶
func (*Service) UpsertPatchAsset ¶ added in v0.8.1
type ServiceDeps ¶ added in v0.6.0
type ServiceDeps struct { AssetRepo Repository DiscoveryRepo DiscoveryRepository LineageRepo LineageRepository Worker Worker Logger log.Logger Config Config }
type SoftDeleteAssetParams ¶ added in v0.9.0
type Type ¶
type Type string
Type specifies a supported type name
func GetSupportedTypes ¶ added in v0.7.7
func GetSupportedTypes() []Type
type Worker ¶ added in v0.6.0
type Worker interface { EnqueueIndexAssetJob(ctx context.Context, ast Asset) error EnqueueDeleteAssetJob(ctx context.Context, urn string) error EnqueueSoftDeleteAssetJob(ctx context.Context, params SoftDeleteAssetParams) error EnqueueDeleteAssetsByQueryExprJob(ctx context.Context, queryExpr string) error EnqueueDeleteAssetsByIsDeletedAndServicesAndUpdatedAtJob(ctx context.Context, isDeleted bool, services []string, expiryThreshold time.Time) error EnqueueSoftDeleteAssetsJob(ctx context.Context, assets []Asset) error EnqueueSyncAssetJob(ctx context.Context, service string) error Close() error }