Skip to content

Commit

Permalink
refactor: rename gcInternal to janitorInterval to avoid confusing wit…
Browse files Browse the repository at this point in the history
…h Go GC (#463)
  • Loading branch information
Tochemey committed Sep 12, 2024
1 parent 5ac03f8 commit 476ce48
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions actors/actor_system.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ type actorSystem struct {
// specifies the stash capacity
stashEnabled bool

stopGC chan types.Unit
gcInterval time.Duration
stopGC chan types.Unit
janitorInterval time.Duration

// specifies the events stream
eventsStream *eventstream.EventsStream
Expand Down Expand Up @@ -252,7 +252,7 @@ func NewActorSystem(name string, opts ...Option) (ActorSystem, error) {
shutdownTimeout: DefaultShutdownTimeout,
stashEnabled: false,
stopGC: make(chan types.Unit, 1),
gcInterval: DefaultGCInterval,
janitorInterval: DefaultJanitorInterval,
eventsStream: eventstream.New(),
partitionHasher: hash.DefaultHasher(),
actorInitTimeout: DefaultInitTimeout,
Expand Down Expand Up @@ -1170,7 +1170,7 @@ func (x *actorSystem) reset() {
// that helps free non-utilized resources
func (x *actorSystem) janitor() {
x.logger.Info("janitor has started...")
ticker := time.NewTicker(x.gcInterval)
ticker := time.NewTicker(x.janitorInterval)
tickerStopSig := make(chan types.Unit, 1)
go func() {
for {
Expand Down
4 changes: 2 additions & 2 deletions actors/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,7 @@ func TestRemoteAsk(t *testing.T) {
sys, err := NewActorSystem("test",
WithLogger(logger),
WithPassivationDisabled(),
WithGCInterval(30*time.Millisecond),
WithJanitorInterval(30*time.Millisecond),
WithRemoting(host, int32(remotingPort)),
)
// assert there are no error
Expand Down Expand Up @@ -1436,7 +1436,7 @@ func TestRemoteAsk(t *testing.T) {
sys, err := NewActorSystem("test",
WithLogger(logger),
WithPassivationDisabled(),
WithGCInterval(30*time.Millisecond),
WithJanitorInterval(30*time.Millisecond),
WithRemoting(host, int32(remotingPort)),
)
// assert there are no error
Expand Down
6 changes: 3 additions & 3 deletions actors/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ func WithPeerStateLoopInterval(interval time.Duration) Option {
})
}

// WithGCInterval sets the GC interval
func WithGCInterval(interval time.Duration) Option {
// WithJanitorInterval sets the janitor interval
func WithJanitorInterval(interval time.Duration) Option {
return OptionFunc(func(system *actorSystem) {
system.gcInterval = interval
system.janitorInterval = interval
})
}
4 changes: 2 additions & 2 deletions actors/option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ func TestOption(t *testing.T) {
},
{
name: "WithGCInterval",
option: WithGCInterval(2 * time.Second),
expected: actorSystem{gcInterval: 2. * time.Second},
option: WithJanitorInterval(2 * time.Second),
expected: actorSystem{janitorInterval: 2. * time.Second},
},
}
for _, tc := range testCases {
Expand Down
4 changes: 2 additions & 2 deletions actors/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ const (
// DefaultPeerStateLoopInterval defines the default peer state loop interval
DefaultPeerStateLoopInterval = 10 * time.Second

// DefaultGCInterval defines the default GC interval
// DefaultJanitorInterval defines the default GC interval
// This helps cleanup dead actors from the given actor system
DefaultGCInterval = 30 * time.Millisecond
DefaultJanitorInterval = 30 * time.Millisecond
// eventsTopic defines the events topic
eventsTopic = "topic.events"

Expand Down

0 comments on commit 476ce48

Please sign in to comment.