-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpartition_metadata.go
36 lines (30 loc) · 1.34 KB
/
partition_metadata.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
package spream
import "time"
// PartitionMetadata contains partition tokens and timestamps that have already been read from the stream partition.
type PartitionMetadata struct {
PartitionToken string `spanner:"PartitionToken" json:"partition_token"`
ParentTokens []string `spanner:"ParentTokens" json:"parent_tokens"`
StartTimestamp time.Time `spanner:"StartTimestamp" json:"start_timestamp"`
EndTimestamp time.Time `spanner:"EndTimestamp" json:"end_timestamp"`
HeartbeatMillis int64 `spanner:"HeartbeatMillis" json:"heartbeat_millis"`
State State `spanner:"State" json:"state"`
Watermark time.Time `spanner:"Watermark" json:"watermark"`
CreatedAt time.Time `spanner:"CreatedAt" json:"created_at"`
ScheduledAt *time.Time `spanner:"ScheduledAt" json:"scheduled_at,omitempty"`
RunningAt *time.Time `spanner:"RunningAt" json:"running_at,omitempty"`
FinishedAt *time.Time `spanner:"FinishedAt" json:"finished_at,omitempty"`
}
type State string
const (
StateCreated State = "CREATED"
StateScheduled State = "SCHEDULED"
StateRunning State = "RUNNING"
StateFinished State = "FINISHED"
)
const (
RootPartitionToken = "Parent0"
)
// IsRootPartition returns true if this is root partition.
func (p *PartitionMetadata) IsRootPartition() bool {
return p.PartitionToken == RootPartitionToken
}