File size: 727 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
package swogrp

import (
	"context"

	"github.com/google/uuid"
	"github.com/target/goalert/swo/swomsg"
	"github.com/target/goalert/util/log"
)

type TaskFn func(context.Context) error

// Config is the configuration for a switchover group.
type Config struct {
	// NodeID is the unique ID of the current node.
	NodeID uuid.UUID

	// CanExec indicates this member is allowed to execute tasks.
	CanExec bool

	// OldID and NewID represents the database IDs of the old and new databases, respectively.
	OldID, NewID uuid.UUID

	Logger   *log.Logger
	Messages *swomsg.Log

	PauseFunc  TaskFn
	ResumeFunc TaskFn

	Executor Executor
}

type Executor interface {
	Sync(context.Context) error
	Exec(context.Context) error

	Cancel()
}