Skip to content

Commit

Permalink
fix!: unexport NewTask
Browse files Browse the repository at this point in the history
client code should not be using this to construct tasks, the runtime
will do this via the Run function
  • Loading branch information
justenwalker committed Mar 31, 2021
1 parent 4dc5db9 commit 9a6d24b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gw/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func Run(fn func(ts *Task) error) error {
if err != nil {
return fmt.Errorf("fail to configure TLS: %w", err)
}
c, err := NewTask(addr, Runtime{
c, err := newTask(addr, runtime{
OrgName: orgName,
WorkingDir: os.Getenv(EnvWorkingDir),
ProcessID: os.Getenv(EnvProcessID),
Expand Down
20 changes: 12 additions & 8 deletions gw/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,32 @@ import (
"google.golang.org/grpc"
)

// NewTask creates a new Task connection between the client and the GRPC service on the agent
func NewTask(addr string, rt Runtime, opts ...grpc.DialOption) (*Task, error) {
// newTask creates a new Task connection between the client and the GRPC service on the agent
func newTask(addr string, rt runtime, opts ...grpc.DialOption) (*Task, error) {
conn, err := grpc.Dial(addr, opts...)
if err != nil {
return nil, fmt.Errorf("unable to connect to grpc server %q: %w", addr, err)
}
return &Task{
Runtime: rt,
conn: conn,
OrgName: rt.OrgName,
WorkingDir: rt.WorkingDir,
ProcessID: rt.ProcessID,
conn: conn,
}, nil
}

// Runtime contains the process runtime information given by the goodwill plugin
type Runtime struct {
// runtime contains the process runtime information
type runtime struct {
OrgName string
WorkingDir string
ProcessID string
}

type Task struct {
Runtime
conn *grpc.ClientConn
OrgName string
WorkingDir string
ProcessID string
conn *grpc.ClientConn
}

const (
Expand Down

0 comments on commit 9a6d24b

Please sign in to comment.