-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c32efca
commit a83c0b4
Showing
9 changed files
with
38 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,35 @@ | ||
package plugins | ||
|
||
import ( | ||
"os/exec" | ||
|
||
"github.com/smartcontractkit/chainlink-common/pkg/loop" | ||
) | ||
|
||
// RegistrarConfig generates contains static configuration inher | ||
type RegistrarConfig interface { | ||
RegisterLOOP(loopId string, cmdName string) (func() *exec.Cmd, loop.GRPCOpts, error) | ||
RegisterLOOP(loopId string, cmdName string) (*RegisteredLoop, error) | ||
GRPCOpts() loop.GRPCOpts | ||
} | ||
|
||
type registarConfig struct { | ||
type registrarConfig struct { | ||
grpcOpts loop.GRPCOpts | ||
loopRegistrationFn func(loopId string) (*RegisteredLoop, error) | ||
loopRegistrationFn func(id, cmd string) (*RegisteredLoop, error) | ||
} | ||
|
||
// NewRegistrarConfig creates a RegistarConfig | ||
// loopRegistrationFn must act as a global registry function of LOOPs and must be idempotent. | ||
// The [func() *exec.Cmd] for a LOOP should be generated by calling [RegistrarConfig.RegisterLOOP] | ||
func NewRegistrarConfig(grpcOpts loop.GRPCOpts, loopRegistrationFn func(loopId string) (*RegisteredLoop, error)) RegistrarConfig { | ||
return ®istarConfig{ | ||
func NewRegistrarConfig(grpcOpts loop.GRPCOpts, loopRegistrationFn func(id, cmd string) (*RegisteredLoop, error)) RegistrarConfig { | ||
return ®istrarConfig{ | ||
grpcOpts: grpcOpts, | ||
loopRegistrationFn: loopRegistrationFn, | ||
} | ||
} | ||
|
||
// RegisterLOOP calls the configured loopRegistrationFn. The loopRegistrationFn must act as a global registry for LOOPs and must be idempotent. | ||
func (pc *registarConfig) RegisterLOOP(loopID string, cmdName string) (func() *exec.Cmd, loop.GRPCOpts, error) { | ||
cmdFn, err := NewCmdFactory(pc.loopRegistrationFn, CmdConfig{ | ||
ID: loopID, | ||
Cmd: cmdName, | ||
}) | ||
if err != nil { | ||
return nil, loop.GRPCOpts{}, err | ||
} | ||
return cmdFn, pc.grpcOpts, nil | ||
func (pc *registrarConfig) RegisterLOOP(id, cmd string) (*RegisteredLoop, error) { | ||
return pc.loopRegistrationFn(id, cmd) | ||
} | ||
|
||
func (pc *registrarConfig) GRPCOpts() loop.GRPCOpts { | ||
return pc.grpcOpts | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.