-
Notifications
You must be signed in to change notification settings - Fork 567
/
util.go
30 lines (25 loc) · 959 Bytes
/
util.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
package track
import (
"context"
"time"
"github.com/pachyderm/pachyderm/v2/src/internal/dbutil"
"github.com/pachyderm/pachyderm/v2/src/internal/errors"
"github.com/pachyderm/pachyderm/v2/src/internal/pachsql"
)
// Create creates uses tracker to create the object id.
func Create(ctx context.Context, tr Tracker, id string, pointsTo []string, ttl time.Duration) error {
return dbutil.WithTx(ctx, tr.DB(), func(ctx context.Context, tx *pachsql.Tx) error {
return errors.EnsureStack(tr.CreateTx(tx, id, pointsTo, ttl))
})
}
// Delete deletes id from the tracker
func Delete(ctx context.Context, tr Tracker, id string) error {
return dbutil.WithTx(ctx, tr.DB(), func(ctx context.Context, tx *pachsql.Tx) error {
return errors.EnsureStack(tr.DeleteTx(tx, id))
})
}
// Drop sets the object at id to expire now
func Drop(ctx context.Context, tr Tracker, id string) error {
_, err := tr.SetTTL(ctx, id, ExpireNow)
return errors.EnsureStack(err)
}