forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fakevtworkerclient.go
40 lines (32 loc) · 1.52 KB
/
fakevtworkerclient.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
37
38
39
40
// 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 fakevtworkerclient contains a fake for the vtworkerclient interface.
package fakevtworkerclient
import (
"time"
"github.com/youtube/vitess/go/vt/logutil"
"github.com/youtube/vitess/go/vt/vtctl/fakevtctlclient"
"github.com/youtube/vitess/go/vt/worker/vtworkerclient"
"golang.org/x/net/context"
)
// FakeVtworkerClient is a fake which implements the vtworkerclient interface.
// The fake can be used to return a specific result for a given command.
// If the command is not registered, an error will be thrown.
type FakeVtworkerClient struct {
fakevtctlclient.FakeLoggerEventStreamingClient
}
// NewFakeVtworkerClient creates a FakeVtworkerClient struct.
func NewFakeVtworkerClient() *FakeVtworkerClient {
return &FakeVtworkerClient{fakevtctlclient.NewFakeLoggerEventStreamingClient()}
}
// FakeVtworkerClientFactory always returns the current instance.
func (f *FakeVtworkerClient) FakeVtworkerClientFactory(addr string, dialTimeout time.Duration) (vtworkerclient.VtworkerClient, error) {
return f, nil
}
// ExecuteVtworkerCommand is part of the vtworkerclient interface.
func (f *FakeVtworkerClient) ExecuteVtworkerCommand(ctx context.Context, args []string) (<-chan *logutil.LoggerEvent, vtworkerclient.ErrFunc, error) {
return f.FakeLoggerEventStreamingClient.StreamResult(args)
}
// Close is part of the vtworkerclient interface.
func (f *FakeVtworkerClient) Close() {}