Skip to content

Commit

Permalink
Release v0.12.4 (#237)
Browse files Browse the repository at this point in the history
* Revert "Release v0.12.3 (#235)"

This reverts commit 28e6b15.

* feat: add job deploy command (#231)

* feat: add job deploy command

* chore: fix lint issue

* refactor: remove unused code in job deploy command

* refactor: read specs at once in job deploy

* feat: add client handle catch error on stream.Send EOF (#232)

* feat: add keepalive enforcement policy 2m on server side (#233)

* feat: add keepalive enforcement policy 2m on server side

* fix: linter magic number on config keepalive enforcement policy

---------

Co-authored-by: Arinda Arif <[email protected]>
  • Loading branch information
okysetiawan and arinda-arif authored Jun 12, 2024
1 parent 28e6b15 commit 47fe92c
Show file tree
Hide file tree
Showing 34 changed files with 825 additions and 3,161 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: golangci/golangci-lint-action@v3
with:
skip-go-installation: true
version: v1.55.2
version: v1.51.1
unit-test:
runs-on: ubuntu-latest
steps:
Expand Down
132 changes: 65 additions & 67 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,94 +1,89 @@
run:
timeout: 5m
go: "1.20"
skip-dirs:
- api/proto
- api/third_party
output:
format: colored-line-number
linters:
disable-all: true
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- decorder
- dogsled
- dupword
- durationcheck
- errname
- errorlint
- execinquery
- exportloopref
- forbidigo
- gci
- ginkgolinter
- gocheckcompilerdirectives
- gochecknoinits
- gochecksumtype
- gocritic
- gofmt
- gofumpt
- goheader
- goimports
- gomnd
- gomodguard
- goprintffuncname
- gosec
- gosimple
- govet
- grouper
- importas
- ineffassign
- loggercheck
- makezero
- mirror
- misspell
- nakedret
- nilerr
- nilnil
- noctx
- nosprintfhostport
- predeclared
- reassign
- revive
- sloglint
- sqlclosecheck
- staticcheck
- stylecheck
- tenv
- testableexamples
- testpackage
- thelper
- tparallel
- unconvert
- unparam
- unused
- usestdlibvars
- whitespace
- zerologlint
enable-all: true
disable:
# Rules to review
- varnamelen
- wrapcheck
- tagliatelle
- paralleltest
- nlreturn
- gochecknoglobals
- exhaustivestruct
- forcetypeassert
- exhaustive
- wsl
- scopelint
- promlinter
- interfacer
- godox
- godot
- errcheck
- maintidx
- errchkjson
- nosnakecase
- nonamedreturns
- exhaustruct
- rowserrcheck
- structcheck
- wastedassign
- gomoddirectives

# Following linters should be enabled after fixing the code
- cyclop
- ireturn
- goerr113
- prealloc
- nestif
- lll
- maligned
- golint
- gocognit
- funlen
- gocyclo
- dupl
- nolintlint
- musttag
- interfacebloat
linters-settings:
gofumpt:
lang-version: "1.19"
extra-rules: true
revive:
severity: error
rules:
- name: atomic
- name: context-as-argument
# - name: context-keys-type #perf issue
- name: defer
- name: dot-imports
- name: empty-block
- name: error-naming
- name: error-return
# - name: error-strings
- name: early-return
# - name: errorf #perf issue
# - name: exported
- name: if-return
- name: increment-decrement
- name: indent-error-flow
# - name: flag-parameter
- name: modifies-parameter
# - name: modifies-value-receiver #perf issue
- name: package-comments
- name: range
- name: receiver-naming
- name: redefines-builtin-id
- name: superfluous-else
# - name: time-naming #perf issue
- name: unexported-naming
# - name: var-declaration #perf issue
- name: var-naming
- name: unused-receiver
- name: unused-parameter
Expand Down Expand Up @@ -116,10 +111,12 @@ linters-settings:
excludes:
- G101
gosimple:
go: "1.19"
checks:
- "all"
- "-S1002"
staticcheck:
go: "1.19"
checks:
- "all"
- "-SA1019"
Expand All @@ -134,16 +131,17 @@ linters-settings:
disabled-checks:
- ifElseChain
- singleCaseSwitch
- hugeParam
enabled-tags:
- diagnostic
# - style
# - opinionated
- performance
unparam:
# Inspect exported functions.
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
check-exported: true
issues:
exclude-dirs:
- api/proto
- api/third_party
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ NAME = "github.com/goto/optimus"
LAST_COMMIT := $(shell git rev-parse --short HEAD)
LAST_TAG := "$(shell git rev-list --tags --max-count=1)"
OPMS_VERSION := "$(shell git describe --tags ${LAST_TAG})-next"
PROTON_COMMIT := "1090b06ae7c9a95bb3086b55d068b949e50b2aa0"
PROTON_COMMIT := "f9c7065042b7465da89125d5a16f0ed930bc9588"


.PHONY: build test test-ci generate-proto unit-test-ci integration-test vet coverage clean install lint
Expand Down Expand Up @@ -58,7 +58,7 @@ lint:

install: ## install required dependencies
@echo "> installing dependencies"
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.1
go install google.golang.org/protobuf/cmd/[email protected]
go install github.com/bufbuild/buf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
Expand Down
3 changes: 2 additions & 1 deletion client/cmd/plugin/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func (v *validateCommand) RunE(_ *cobra.Command, _ []string) error {
return nil
} else if fm.IsDir() {
return v.validateDir(v.path)
} else {
return errors.New("invalid path")
}
return errors.New("invalid path")
}
9 changes: 0 additions & 9 deletions config.sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,3 @@ log:
# batch_interval_second: 1
# broker_urls:
# - localhost:9092

# replay:
# plugin_execution_project_config_names:
# bq2bq: EXECUTION_PROJECT
# bq2pg: BQ_EXECUTION_PROJECT
# pg2bq: BQ_EXECUTION_PROJECT
# bq2api: EXECUTION_PROJECT
# clevertap: EXECUTION_PROJECT
# transporterTask: EXECUTION_PROJECT
5 changes: 2 additions & 3 deletions config/config_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ type PluginConfig struct {
}

type ReplayConfig struct {
ReplayTimeoutInMinutes int `mapstructure:"replay_timeout_in_minutes" default:"180"`
ExecutionIntervalInSeconds int `mapstructure:"execution_interval_in_seconds" default:"120"`
PluginExecutionProjectConfigNames map[string]string `mapstructure:"plugin_execution_project_config_names"`
ReplayTimeoutInMinutes int `mapstructure:"replay_timeout_in_minutes" default:"180"`
ExecutionIntervalInSeconds int `mapstructure:"execution_interval_in_seconds" default:"120"`
}

type Publisher struct {
Expand Down
46 changes: 6 additions & 40 deletions core/job/handler/v1beta1/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,16 @@ const (
)

type JobHandler struct {
l log.Logger
jobService JobService
changeLogService ChangeLogService
l log.Logger
jobService JobService

pb.UnimplementedJobSpecificationServiceServer
}

func NewJobHandler(jobService JobService, changeLogService ChangeLogService, logger log.Logger) *JobHandler {
func NewJobHandler(jobService JobService, logger log.Logger) *JobHandler {
return &JobHandler{
jobService: jobService,
changeLogService: changeLogService,
l: logger,
jobService: jobService,
l: logger,
}
}

Expand All @@ -62,10 +60,6 @@ type JobService interface {
GetDownstream(ctx context.Context, job *job.Job, localJob bool) ([]*job.Downstream, error)
}

type ChangeLogService interface {
GetChangelog(ctx context.Context, projectName tenant.ProjectName, jobName job.Name) ([]*job.ChangeLog, error)
}

func (jh *JobHandler) AddJobSpecifications(ctx context.Context, jobSpecRequest *pb.AddJobSpecificationsRequest) (*pb.AddJobSpecificationsResponse, error) {
jobTenant, err := tenant.NewTenant(jobSpecRequest.ProjectName, jobSpecRequest.NamespaceName)
if err != nil {
Expand Down Expand Up @@ -224,7 +218,7 @@ func (jh *JobHandler) GetJobSpecification(ctx context.Context, req *pb.GetJobSpe
}
jobName, err := job.NameFrom(req.GetJobName())
if err != nil {
jh.l.Error("error adapting job name [%s]: %s", req.GetJobName(), err)
jh.l.Error("error adapating job name [%s]: %s", req.GetJobName(), err)
return nil, err
}

Expand All @@ -241,34 +235,6 @@ func (jh *JobHandler) GetJobSpecification(ctx context.Context, req *pb.GetJobSpe
}, nil
}

func (jh *JobHandler) GetJobChangelog(ctx context.Context, req *pb.GetJobChangelogRequest) (*pb.GetJobChangelogResponse, error) {
projectName, err := tenant.ProjectNameFrom(req.GetProjectName())
if err != nil {
jh.l.Error("invalid project information request project [%s]: %s", req.GetProjectName(), err)
return nil, err
}
jobName, err := job.NameFrom(req.GetJobName())
if err != nil {
jh.l.Error("error adapting job name [%s]: %s", req.GetJobName(), err)
return nil, err
}

changeLog, err := jh.changeLogService.GetChangelog(ctx, projectName, jobName)
if err != nil && !errors.IsErrorType(err, errors.ErrNotFound) {
errorMsg := "failed to get job specification"
jh.l.Error(fmt.Sprintf("%s: %s", err.Error(), errorMsg))
return nil, errors.GRPCErr(err, errorMsg)
}
history := make([]*pb.JobChangelog, len(changeLog))
for i, clog := range changeLog {
history[i] = toJobChangeLogProto(clog)
}

return &pb.GetJobChangelogResponse{
History: history,
}, nil
}

func (jh *JobHandler) GetJobSpecifications(ctx context.Context, req *pb.GetJobSpecificationsRequest) (*pb.GetJobSpecificationsResponse, error) {
jobSpecs, merr := jh.jobService.GetByFilter(ctx,
filter.WithString(filter.ResourceDestination, req.GetResourceDestination()),
Expand Down
15 changes: 0 additions & 15 deletions core/job/handler/v1beta1/job_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -540,21 +540,6 @@ func toUpstreamProtos(upstreams []*job.Upstream, upstreamSpec *job.UpstreamSpec,
}
}

func toJobChangeLogProto(changeLog *job.ChangeLog) *pb.JobChangelog {
pbChange := &pb.JobChangelog{
EventType: changeLog.Type,
Timestamp: changeLog.Time.String(),
}
pbChange.Change = make([]*pb.JobChange, len(changeLog.Change))
for i, change := range changeLog.Change {
pbChange.Change[i] = &pb.JobChange{
AttributeName: change.Property,
Diff: change.Diff,
}
}
return pbChange
}

func toHTTPUpstreamProtos(httpUpstreamSpecs []*job.SpecHTTPUpstream) []*pb.HttpDependency {
var httpUpstreamProtos []*pb.HttpDependency
for _, httpUpstream := range httpUpstreamSpecs {
Expand Down
Loading

0 comments on commit 47fe92c

Please sign in to comment.