Skip to content

Commit

Permalink
Rename StreamRegistry => Registry
Browse files Browse the repository at this point in the history
  • Loading branch information
samsondav committed Jan 11, 2024
1 parent fe899c6 commit 40173fb
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion core/services/chainlink/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func NewApplication(opts ApplicationOpts) (Application, error) {
pipelineRunner = pipeline.NewRunner(pipelineORM, bridgeORM, cfg.JobPipeline(), cfg.WebServer(), legacyEVMChains, keyStore.Eth(), keyStore.VRF(), globalLogger, restrictedHTTPClient, unrestrictedHTTPClient)
jobORM = job.NewORM(db, pipelineORM, bridgeORM, keyStore, globalLogger, cfg.Database())
txmORM = txmgr.NewTxStore(db, globalLogger, cfg.Database())
streamRegistry = streams.NewStreamRegistry(globalLogger, pipelineRunner)
streamRegistry = streams.NewRegistry(globalLogger, pipelineRunner)
)

for _, chain := range legacyEVMChains.Slice() {
Expand Down
6 changes: 3 additions & 3 deletions core/services/streams/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ type DelegateConfig interface {

type Delegate struct {
lggr logger.Logger
registry StreamRegistry
registry Registry
runner ocrcommon.Runner
cfg DelegateConfig
}

var _ job.Delegate = (*Delegate)(nil)

func NewDelegate(lggr logger.Logger, registry StreamRegistry, runner ocrcommon.Runner, cfg DelegateConfig) *Delegate {
func NewDelegate(lggr logger.Logger, registry Registry, runner ocrcommon.Runner, cfg DelegateConfig) *Delegate {
return &Delegate{lggr, registry, runner, cfg}
}

Expand Down Expand Up @@ -66,7 +66,7 @@ type ResultRunSaver interface {
}

type StreamService struct {
registry StreamRegistry
registry Registry
id StreamID
spec *pipeline.Spec
lggr logger.Logger
Expand Down
10 changes: 5 additions & 5 deletions core/services/streams/stream_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func (s StreamID) String() string {
return string(s)
}

type StreamRegistry interface {
type Registry interface {
Get(streamID StreamID) (strm Stream, exists bool)
Register(streamID StreamID, spec pipeline.Spec, rrs ResultRunSaver) error
Unregister(streamID StreamID)
Expand All @@ -27,14 +27,14 @@ type streamRegistry struct {
streams map[StreamID]Stream
}

func NewStreamRegistry(lggr logger.Logger, runner Runner) StreamRegistry {
return newStreamRegistry(lggr, runner)
func NewRegistry(lggr logger.Logger, runner Runner) Registry {
return newRegistry(lggr, runner)
}

func newStreamRegistry(lggr logger.Logger, runner Runner) *streamRegistry {
func newRegistry(lggr logger.Logger, runner Runner) *streamRegistry {
return &streamRegistry{
sync.RWMutex{},
lggr.Named("StreamRegistry"),
lggr.Named("Registry"),
runner,
make(map[StreamID]Stream),
}
Expand Down
8 changes: 4 additions & 4 deletions core/services/streams/stream_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ func (m *mockStream) Run(ctx context.Context) (*pipeline.Run, pipeline.TaskRunRe
return m.run, m.trrs, m.err
}

func Test_StreamRegistry(t *testing.T) {
func Test_Registry(t *testing.T) {
lggr := logger.TestLogger(t)
runner := &mockRunner{}

t.Run("Get", func(t *testing.T) {
sr := newStreamRegistry(lggr, runner)
sr := newRegistry(lggr, runner)

sr.streams["foo"] = &mockStream{run: &pipeline.Run{ID: 1}}
sr.streams["bar"] = &mockStream{run: &pipeline.Run{ID: 2}}
Expand All @@ -49,7 +49,7 @@ func Test_StreamRegistry(t *testing.T) {
assert.False(t, exists)
})
t.Run("Register", func(t *testing.T) {
sr := newStreamRegistry(lggr, runner)
sr := newRegistry(lggr, runner)

t.Run("registers new stream", func(t *testing.T) {
assert.Len(t, sr.streams, 0)
Expand Down Expand Up @@ -79,7 +79,7 @@ func Test_StreamRegistry(t *testing.T) {
})
})
t.Run("Unregister", func(t *testing.T) {
sr := newStreamRegistry(lggr, runner)
sr := newRegistry(lggr, runner)

sr.streams["foo"] = &mockStream{run: &pipeline.Run{ID: 1}}
sr.streams["bar"] = &mockStream{run: &pipeline.Run{ID: 2}}
Expand Down

0 comments on commit 40173fb

Please sign in to comment.