Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions states/etcd/common/wal_recovery_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,28 @@ func SaveVChannelMeta(ctx context.Context, cli kv.MetaKV, basePath string, meta
}
return cli.Save(ctx, key, string(bs))
}

// ConsumeCheckpointKey returns the etcd key holding the pchannel's consume checkpoint.
func ConsumeCheckpointKey(basePath string, pchannel string) string {
return path.Join(basePath, walRecoveryStoragePrefix, pchannel, walRecoveryStorageConsumeCheckpoint)
}

// SaveConsumeCheckpoint overwrites the consume checkpoint of a pchannel.
//
// The checkpoint is what streamingnode reads to decide which WAL implementation
// to open, so writing it is the commit point of any WAL switch — callers should
// write everything else first.
func SaveConsumeCheckpoint(ctx context.Context, cli kv.MetaKV, basePath string, pchannel string, checkpoint *streamingpb.WALCheckpoint) error {
data, err := proto.Marshal(checkpoint)
if err != nil {
return errors.Wrapf(err, "failed to marshal consume checkpoint for pchannel %s", pchannel)
}
return cli.Save(ctx, ConsumeCheckpointKey(basePath, pchannel), string(data))
}

// SegmentAssignPrefix returns the prefix holding a pchannel's growing-segment
// allocations. They are checkpointed against WAL offsets, so a WAL switch
// invalidates all of them.
func SegmentAssignPrefix(basePath string, pchannel string) string {
return path.Join(basePath, walRecoveryStoragePrefix, pchannel, walRecoveryStorageDirectorySegmentAssign)
}
Loading
Loading