mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-03 03:56:04 +00:00
Full module path rebrand from Temporal to Hanzo Tasks: - go.mod module: github.com/hanzoai/tasks - All internal Go imports updated (1906 files) - cmd/server renamed to cmd/tasksd - Binary name: tasksd (was temporal-server) - Docker images: hanzoai/tasks (was temporalio/server) - README rewritten with Hanzo Tasks branding - LLM.md created with integration notes - Makefile, goreleaser, CI workflows updated - go.temporal.io/sdk and go.temporal.io/api imports preserved (separate repos) Fork of Temporal.io (MIT license).
54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
package circuitbreaker
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/suite"
|
|
"github.com/hanzoai/tasks/common/dynamicconfig"
|
|
)
|
|
|
|
type TSCBWithDynamicSettingsTestSuite struct {
|
|
suite.Suite
|
|
}
|
|
|
|
func TestTSCBWithDynamicSettings(t *testing.T) {
|
|
suite.Run(t, &TSCBWithDynamicSettingsTestSuite{})
|
|
}
|
|
|
|
func TestBasic(t *testing.T) {
|
|
s := assert.New(t)
|
|
|
|
name := "test-tscb"
|
|
tscb := NewTwoStepCircuitBreakerWithDynamicSettings(Settings{Name: name})
|
|
tscb.UpdateSettings(dynamicconfig.CircuitBreakerSettings{})
|
|
s.Equal(name, tscb.Name())
|
|
|
|
doneFn, err := tscb.Allow()
|
|
s.NoError(err)
|
|
doneFn(true)
|
|
}
|
|
|
|
func TestDynamicSettings(t *testing.T) {
|
|
s := assert.New(t)
|
|
|
|
tscb := NewTwoStepCircuitBreakerWithDynamicSettings(Settings{})
|
|
tscb.UpdateSettings(dynamicconfig.CircuitBreakerSettings{})
|
|
cb1 := tscb.cb.Load()
|
|
|
|
// should not change
|
|
tscb.UpdateSettings(dynamicconfig.CircuitBreakerSettings{})
|
|
cb2 := tscb.cb.Load()
|
|
s.Equal(cb2, cb1)
|
|
|
|
// should change
|
|
tscb.UpdateSettings(dynamicconfig.CircuitBreakerSettings{
|
|
MaxRequests: 2,
|
|
Interval: 3600 * time.Second,
|
|
Timeout: 30 * time.Second,
|
|
})
|
|
cb3 := tscb.cb.Load()
|
|
s.NotEqual(cb3, cb2)
|
|
}
|