Skip to content

Commit b16d7bf

Browse files
JoshVanLdapr-bot
andauthored
Actors: Vanity rename engine -> router (dapr#8658)
* Actors: Vanity rename engine -> router Vanity package and struct rename of actor `engine` to `router`. The name `router` far better fits the purpose of this package since its main/sole focus is routing messages to correct targets. The whole `/pkg/actor` package hierarchy should be considered the engine. Signed-off-by: joshvanl <[email protected]> * Remove unused func Signed-off-by: joshvanl <[email protected]> --------- Signed-off-by: joshvanl <[email protected]> Co-authored-by: Dapr Bot <[email protected]>
1 parent be29873 commit b16d7bf

File tree

21 files changed

+135
-132
lines changed

21 files changed

+135
-132
lines changed

pkg/actors/actors.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525

2626
"github.com/dapr/components-contrib/state"
2727
"github.com/dapr/dapr/pkg/actors/api"
28-
"github.com/dapr/dapr/pkg/actors/engine"
2928
"github.com/dapr/dapr/pkg/actors/hostconfig"
3029
"github.com/dapr/dapr/pkg/actors/internal/apilevel"
3130
"github.com/dapr/dapr/pkg/actors/internal/locker"
@@ -37,6 +36,7 @@ import (
3736
internaltimers "github.com/dapr/dapr/pkg/actors/internal/timers"
3837
"github.com/dapr/dapr/pkg/actors/internal/timers/inmemory"
3938
"github.com/dapr/dapr/pkg/actors/reminders"
39+
"github.com/dapr/dapr/pkg/actors/router"
4040
actorstate "github.com/dapr/dapr/pkg/actors/state"
4141
"github.com/dapr/dapr/pkg/actors/table"
4242
"github.com/dapr/dapr/pkg/actors/targets"
@@ -88,7 +88,7 @@ type InitOptions struct {
8888
type Interface interface {
8989
Init(InitOptions) error
9090
Run(context.Context) error
91-
Engine(context.Context) (engine.Interface, error)
91+
Router(context.Context) (router.Interface, error)
9292
Table(context.Context) (table.Interface, error)
9393
State(context.Context) (actorstate.Interface, error)
9494
Timers(context.Context) (timers.Interface, error)
@@ -117,7 +117,7 @@ type actors struct {
117117
reminders reminders.Interface
118118
table table.Interface
119119
placement placement.Interface
120-
engine engine.Interface
120+
router router.Interface
121121
timerStorage internaltimers.Storage
122122
timers timers.Interface
123123
idlerQueue *queue.Processor[string, targets.Idlable]
@@ -227,7 +227,7 @@ func (a *actors) Init(opts InitOptions) error {
227227
})
228228
}
229229

230-
a.engine = engine.New(engine.Options{
230+
a.router = router.New(router.Options{
231231
Namespace: a.namespace,
232232
SchedulerReminders: a.schedulerReminders,
233233
Placement: a.placement,
@@ -241,15 +241,15 @@ func (a *actors) Init(opts InitOptions) error {
241241
})
242242

243243
a.timerStorage = inmemory.New(inmemory.Options{
244-
Engine: a.engine,
244+
Router: a.router,
245245
})
246246
a.timers = timers.New(timers.Options{
247247
Storage: a.timerStorage,
248248
Table: a.table,
249249
})
250250

251251
if a.stateReminders != nil {
252-
a.stateReminders.SetEngine(a.engine)
252+
a.stateReminders.SetRouter(a.router)
253253
}
254254

255255
return nil
@@ -318,12 +318,12 @@ func (a *actors) Run(ctx context.Context) error {
318318
return mngr.Run(ctx)
319319
}
320320

321-
func (a *actors) Engine(ctx context.Context) (engine.Interface, error) {
321+
func (a *actors) Router(ctx context.Context) (router.Interface, error) {
322322
if err := a.waitForReady(ctx); err != nil {
323323
return nil, err
324324
}
325325

326-
return a.engine, nil
326+
return a.router, nil
327327
}
328328

329329
func (a *actors) Table(ctx context.Context) (table.Interface, error) {

pkg/actors/fake/fake.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ import (
1717
"context"
1818

1919
"github.com/dapr/dapr/pkg/actors"
20-
"github.com/dapr/dapr/pkg/actors/engine"
21-
enginefake "github.com/dapr/dapr/pkg/actors/engine/fake"
2220
"github.com/dapr/dapr/pkg/actors/hostconfig"
2321
"github.com/dapr/dapr/pkg/actors/reminders"
2422
remindersfake "github.com/dapr/dapr/pkg/actors/reminders/fake"
23+
"github.com/dapr/dapr/pkg/actors/router"
24+
routerfake "github.com/dapr/dapr/pkg/actors/router/fake"
2525
"github.com/dapr/dapr/pkg/actors/state"
2626
statefake "github.com/dapr/dapr/pkg/actors/state/fake"
2727
"github.com/dapr/dapr/pkg/actors/table"
@@ -33,7 +33,7 @@ import (
3333
type Fake struct {
3434
fnInit func(actors.InitOptions) error
3535
fnRun func(context.Context) error
36-
fnEngine func(context.Context) (engine.Interface, error)
36+
fnRouter func(context.Context) (router.Interface, error)
3737
fnTable func(context.Context) (table.Interface, error)
3838
fnState func(context.Context) (state.Interface, error)
3939
fnTimers func(context.Context) (timers.Interface, error)
@@ -52,8 +52,8 @@ func New() *Fake {
5252
fnRun: func(context.Context) error {
5353
return nil
5454
},
55-
fnEngine: func(context.Context) (engine.Interface, error) {
56-
return enginefake.New(), nil
55+
fnRouter: func(context.Context) (router.Interface, error) {
56+
return routerfake.New(), nil
5757
},
5858
fnTable: func(context.Context) (table.Interface, error) {
5959
return nil, nil
@@ -90,8 +90,8 @@ func (f *Fake) WithRun(fn func(context.Context) error) *Fake {
9090
return f
9191
}
9292

93-
func (f *Fake) WithEngine(fn func(context.Context) (engine.Interface, error)) *Fake {
94-
f.fnEngine = fn
93+
func (f *Fake) WithRouter(fn func(context.Context) (router.Interface, error)) *Fake {
94+
f.fnRouter = fn
9595
return f
9696
}
9797

@@ -143,8 +143,8 @@ func (f *Fake) Run(ctx context.Context) error {
143143
return f.fnRun(ctx)
144144
}
145145

146-
func (f *Fake) Engine(ctx context.Context) (engine.Interface, error) {
147-
return f.fnEngine(ctx)
146+
func (f *Fake) Router(ctx context.Context) (router.Interface, error) {
147+
return f.fnRouter(ctx)
148148
}
149149

150150
func (f *Fake) Table(ctx context.Context) (table.Interface, error) {

pkg/actors/internal/reminders/storage/statestore/statestore.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ import (
3131

3232
"github.com/dapr/components-contrib/state"
3333
"github.com/dapr/dapr/pkg/actors/api"
34-
"github.com/dapr/dapr/pkg/actors/engine"
3534
actorerrors "github.com/dapr/dapr/pkg/actors/errors"
3635
"github.com/dapr/dapr/pkg/actors/internal/apilevel"
3736
"github.com/dapr/dapr/pkg/actors/internal/key"
37+
"github.com/dapr/dapr/pkg/actors/router"
3838
actorstate "github.com/dapr/dapr/pkg/actors/state"
3939
"github.com/dapr/dapr/pkg/actors/table"
4040
diag "github.com/dapr/dapr/pkg/diagnostics"
@@ -74,7 +74,7 @@ type Statestore struct {
7474
resiliency resiliency.Provider
7575
apiLevel *apilevel.APILevel
7676
table table.Interface
77-
engine engine.Interface
77+
router router.Interface
7878
closed atomic.Bool
7979
wg sync.WaitGroup
8080

@@ -1079,7 +1079,7 @@ func (r *Statestore) startReminder(reminder *api.Reminder, stop *reminderStop) e
10791079
break loop
10801080
}
10811081

1082-
err = r.engine.CallReminder(context.TODO(), reminder)
1082+
err = r.router.CallReminder(context.TODO(), reminder)
10831083
diag.DefaultMonitoring.ActorReminderFired(reminder.ActorType, err == nil)
10841084
if errors.Is(err, actorerrors.ErrReminderCanceled) {
10851085
nextTimer = nil
@@ -1197,8 +1197,8 @@ func (r *Statestore) updateReminderTrack(ctx context.Context, key string, repeti
11971197

11981198
// TODO: :(
11991199
// Statestore option will be removed completely in v1.16
1200-
func (r *Statestore) SetEngine(engine engine.Interface) {
1201-
r.engine = engine
1200+
func (r *Statestore) SetRouter(router router.Interface) {
1201+
r.router = router
12021202
}
12031203

12041204
func isEtagMismatchError(err error) bool {

pkg/actors/internal/timers/inmemory/inmemory.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import (
2424
"k8s.io/utils/clock"
2525

2626
"github.com/dapr/dapr/pkg/actors/api"
27-
"github.com/dapr/dapr/pkg/actors/engine"
2827
"github.com/dapr/dapr/pkg/actors/internal/timers"
28+
"github.com/dapr/dapr/pkg/actors/router"
2929
diag "github.com/dapr/dapr/pkg/diagnostics"
3030
"github.com/dapr/kit/events/queue"
3131
"github.com/dapr/kit/logger"
@@ -34,13 +34,13 @@ import (
3434
var log = logger.NewLogger("dapr.runtime.actors.timers.inmemory")
3535

3636
type Options struct {
37-
Engine engine.Interface
37+
Router router.Interface
3838
}
3939

4040
type inmemory struct {
4141
clock clock.WithTicker
4242

43-
engine engine.Interface
43+
router router.Interface
4444
activeTimers *sync.Map
4545
activeTimersCount map[string]*int64
4646
activeTimersCountLock sync.RWMutex
@@ -51,7 +51,7 @@ type inmemory struct {
5151
// New returns a TimerProvider.
5252
func New(opts Options) timers.Storage {
5353
i := &inmemory{
54-
engine: opts.Engine,
54+
router: opts.Router,
5555
clock: clock.RealClock{},
5656
activeTimers: &sync.Map{},
5757
activeTimersCount: make(map[string]*int64),
@@ -70,7 +70,7 @@ func (i *inmemory) Close() error {
7070

7171
// processorExecuteFn is invoked when the processor executes a reminder.
7272
func (i *inmemory) processorExecuteFn(reminder *api.Reminder) {
73-
err := i.engine.CallReminder(context.TODO(), reminder)
73+
err := i.router.CallReminder(context.TODO(), reminder)
7474
diag.DefaultMonitoring.ActorTimerFired(reminder.ActorType, err == nil)
7575
if err != nil {
7676
// Successful and non-successful executions are treated as the same in
File renamed without changes.

pkg/actors/engine/fake/fake_test.go renamed to pkg/actors/router/fake/fake_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ package fake
1616
import (
1717
"testing"
1818

19-
"github.com/dapr/dapr/pkg/actors/engine"
19+
"github.com/dapr/dapr/pkg/actors/router"
2020
)
2121

2222
func Test_Fake(t *testing.T) {
2323
t.Parallel()
24-
var _ engine.Interface = New()
24+
var _ router.Interface = New()
2525
}

0 commit comments

Comments
 (0)