-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
wait_for_filtered_replication_task.go
35 lines (28 loc) · 1.3 KB
/
wait_for_filtered_replication_task.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
// Copyright 2015, Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package automation
import (
"fmt"
pb "github.com/youtube/vitess/go/vt/proto/automation"
"golang.org/x/net/context"
)
// WaitForFilteredReplicationTask runs vtctl WaitForFilteredReplication to block until the destination master
// (i.e. the receiving side of the filtered replication) has caught up up to max_delay with the source shard.
type WaitForFilteredReplicationTask struct {
}
// Run is part of the Task interface.
func (t *WaitForFilteredReplicationTask) Run(parameters map[string]string) ([]*pb.TaskContainer, string, error) {
keyspaceAndShard := fmt.Sprintf("%v/%v", parameters["keyspace"], parameters["shard"])
output, err := ExecuteVtctl(context.TODO(), parameters["vtctld_endpoint"],
[]string{"WaitForFilteredReplication", "-max_delay", parameters["max_delay"], keyspaceAndShard})
return nil, output, err
}
// RequiredParameters is part of the Task interface.
func (t *WaitForFilteredReplicationTask) RequiredParameters() []string {
return []string{"keyspace", "shard", "max_delay", "vtctld_endpoint"}
}
// OptionalParameters is part of the Task interface.
func (t *WaitForFilteredReplicationTask) OptionalParameters() []string {
return nil
}