-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
67 changed files
with
2,606 additions
and
850 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
*.iml | ||
.github | ||
.idea | ||
bin | ||
docs | ||
examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,11 +23,11 @@ build: generate manifests | |
test: | ||
go test -v ./... -coverprofile cover.out | ||
|
||
pre-commit: codegen test install lint | ||
pre-commit: codegen test install lint start | ||
|
||
codegen: generate manifests proto config/ci.yaml config/default.yaml config/dev.yaml config/kafka-default.yaml config/quick-start.yaml config/stan-default.yaml docs/EXAMPLES.md | ||
codegen: generate manifests proto config/ci.yaml config/default.yaml config/dev.yaml config/kafka-default.yaml config/quick-start.yaml config/stan-default.yaml docs/EXAMPLES.md CHANGELOG.md | ||
go generate ./... | ||
./hack/changelog.sh > CHANGELOG.md | ||
|
||
|
||
$(GOBIN)/goreman: | ||
go install github.com/mattn/[email protected] | ||
|
@@ -78,8 +78,12 @@ generate: $(GOBIN)/controller-gen | |
$(GOBIN)/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..." | ||
|
||
.PHONY: docs/EXAMPLES.md | ||
docs/EXAMPLES.md: | ||
go run ./docs/examples > docs/EXAMPLES.md | ||
docs/EXAMPLES.md: /dev/null | ||
go run ./examples > docs/EXAMPLES.md | ||
|
||
.PHONY: CHANGELOG.md | ||
CHANGELOG.md: /dev/null | ||
./hack/changelog.sh > CHANGELOG.md | ||
|
||
# not dependant on api/v1alpha1/generated.proto because it often does not change when this target runs, so results in remakes when they are not needed | ||
proto: api/v1alpha1/generated.pb.go | ||
|
@@ -100,7 +104,7 @@ api/v1alpha1/generated.%: $(shell find api/v1alpha1 -type f -name '*.go' -not -n | |
lint: | ||
go mod tidy | ||
golangci-lint run --fix | ||
kubectl apply --dry-run=client -f docs/examples | ||
kubectl apply --dry-run=client -f examples | ||
|
||
.PHONY: controller | ||
controller: controller-image | ||
|
@@ -153,7 +157,7 @@ config/stan/single-server-stan.yml: | |
|
||
.PHONY: test-examples | ||
test-examples: | ||
go test -timeout 20m -v -tags examples -count 1 ./docs/examples | ||
go test -timeout 20m -v -count 1 ./examples | ||
|
||
argocli: | ||
cd ../../argoproj/argo-workflows && git checkout dev-dataflow && make ./dist/argo DEV_BRANCH=true && ./dist/argo server --secure=false --namespaced --auth-mode=server --namespace=argo-dataflow-system | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package v1alpha1 | ||
|
||
type Scale struct { | ||
MinReplicas int32 `json:"minReplicas,omitempty" protobuf:"varint,1,opt,name=minReplicas"` | ||
MaxReplicas *uint32 `json:"maxReplicas,omitempty" protobuf:"varint,2,opt,name=maxReplicas"` // takes precedence over min | ||
ReplicaRatio uint32 `json:"replicaRatio,omitempty" protobuf:"varint,3,opt,name=replicaRatio"` | ||
} | ||
|
||
// Used to calculate the number of replicas. | ||
// min(r.max, max(r.min, pending/ratio)) | ||
// Example: | ||
// min=1, max=4, ratio=100 | ||
// pending=0, replicas=1 | ||
// pending=100, replicas=1 | ||
// pending=200, replicas=2 | ||
// pending=300, replicas=3 | ||
// pending=400, replicas=4 | ||
// pending=500, replicas=4 | ||
func (in Scale) Calculate(pending int) int { | ||
n := 0 | ||
if in.ReplicaRatio > 0 { | ||
n = pending / int(in.ReplicaRatio) | ||
} | ||
if n < int(in.MinReplicas) { | ||
n = int(in.MinReplicas) | ||
} | ||
if in.MaxReplicas != nil && n > int(*in.MaxReplicas) { | ||
n = int(*in.MaxReplicas) | ||
} | ||
return n | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestScale_Calculate(t *testing.T) { | ||
assert.Equal(t, 0, Scale{MinReplicas: 0}.Calculate(0)) | ||
assert.Equal(t, 0, Scale{MinReplicas: 0}.Calculate(0)) | ||
max := uint32(0) | ||
assert.Equal(t, 0, Scale{MinReplicas: 1, MaxReplicas: &max}.Calculate(0)) | ||
assert.Equal(t, 2, Scale{MinReplicas: 1, ReplicaRatio: 2}.Calculate(4)) | ||
max = uint32(1) | ||
assert.Equal(t, 1, Scale{MinReplicas: 1, MaxReplicas: &max, ReplicaRatio: 2}.Calculate(4)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_trunc(t *testing.T) { | ||
assert.Len(t, trunc(strings.Repeat("x", 99)), 32) | ||
} |
Oops, something went wrong.