mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed? Optimize workflow task timeouts by completing them when the workflow task finishes. This optimization is enabled when the dynamic config system.enableDeleteHistoryTasksOnUpdate is turned on. It is disabled by default, as it can cause performance degradation in cassandra based persistence. ## Why? A large fraction of all timer tasks processed is workflow task timeouts. In most of the cases, these are no-ops. We can complete these tasks when the corresponding workflow task finishes. This will reduce the number of timer tasks processes. ## How did you test it? - [x] built - [ ] run locally and tested manually - [ ] covered by existing tests - [x] added new unit test(s) - [ ] added new functional test(s)
64 lines
1.2 KiB
Go
64 lines
1.2 KiB
Go
package client_test
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"go.temporal.io/server/common/config"
|
|
"go.temporal.io/server/common/persistence/client"
|
|
"go.temporal.io/server/common/persistence/mock"
|
|
"go.uber.org/mock/gomock"
|
|
)
|
|
|
|
func TestFactoryImpl_NewHistoryTaskQueueManager(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
for _, tc := range []struct {
|
|
name string
|
|
err error
|
|
}{
|
|
{
|
|
name: "No error",
|
|
err: nil,
|
|
},
|
|
{
|
|
name: "Error",
|
|
err: errors.New("some error"),
|
|
},
|
|
} {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
ctrl := gomock.NewController(t)
|
|
dataStoreFactory := mock.NewMockDataStoreFactory(ctrl)
|
|
dataStoreFactory.EXPECT().NewQueueV2().Return(nil, tc.err).AnyTimes()
|
|
|
|
factory := client.NewFactory(
|
|
dataStoreFactory,
|
|
&config.Persistence{
|
|
NumHistoryShards: 1,
|
|
},
|
|
nil,
|
|
nil,
|
|
nil,
|
|
nil,
|
|
nil,
|
|
"",
|
|
nil,
|
|
nil,
|
|
nil,
|
|
func() bool { return false },
|
|
func() bool { return false },
|
|
)
|
|
historyTaskQueueManager, err := factory.NewHistoryTaskQueueManager()
|
|
if tc.err != nil {
|
|
require.Error(t, err)
|
|
return
|
|
}
|
|
require.NoError(t, err)
|
|
require.NotNil(t, historyTaskQueueManager)
|
|
})
|
|
}
|
|
}
|