-
Notifications
You must be signed in to change notification settings - Fork 2
/
dataset.go
57 lines (48 loc) · 1.08 KB
/
dataset.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package openlineage
import (
"context"
"time"
"github.com/ThijsKoot/openlineage-go/pkg/facets"
)
// DatasetEvent represents an OpenLineage DatasetEvent.
type DatasetEvent struct {
Dataset Dataset
BaseEvent
}
func (e *DatasetEvent) AsEmittable() Event {
return Event{
EventTime: e.EventTime,
Dataset: &e.Dataset,
Producer: e.Producer,
SchemaURL: e.SchemaURL,
}
}
// Emit calls [Client.Emit] on [DefaultClient].
func (e *DatasetEvent) Emit() {
_ = DefaultClient.Emit(context.Background(), e)
}
func NewDatasetEvent(
name string,
namespace string,
facets ...facets.DatasetFacet,
) DatasetEvent {
return DatasetEvent{
BaseEvent: BaseEvent{
Producer: producer,
SchemaURL: schemaURL,
EventTime: time.Now().Format(time.RFC3339),
},
Dataset: NewDataset(name, namespace, facets...),
}
}
func NewDataset(name string, namespace string, datasetFacets ...facets.DatasetFacet) Dataset {
var dataset *facets.DatasetFacets
for _, f := range datasetFacets {
f.Apply(&dataset)
}
return Dataset{
Name: name,
Namespace: namespace,
Facets: dataset,
}
}