-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathproxy.go
40 lines (32 loc) · 852 Bytes
/
proxy.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
package structural
import (
"fmt"
"io"
"os"
)
var outputWriter io.Writer = os.Stdout // modified during testing
// ITask is an interface for performing tasks.
type ITask interface {
Execute(taskType string)
}
// Task implements the ITask interface for performing tasks.
type Task struct {
}
// Execute implements the task.
func (t *Task) Execute(taskType string) {
fmt.Fprint(outputWriter, "Performing task type: "+taskType)
}
// ProxyTask represents a proxy task with re-routes tasks.
type ProxyTask struct {
task *Task
}
// NewProxyTask creates a new instance of a ProxyTask.
func NewProxyTask() *ProxyTask {
return &ProxyTask{task: &Task{}}
}
// Execute intercepts the Execute command and re-routes it to the Task Execute command.
func (t *ProxyTask) Execute(taskType string) {
if taskType == "Run" {
t.task.Execute(taskType)
}
}