Skip to content

Commit

Permalink
Merge pull request #37 from temporalio/feature/workflow-mode
Browse files Browse the repository at this point in the history
update(constants): move all shared constants to the one place
  • Loading branch information
rustatian authored Mar 2, 2021
2 parents b425f1e + 344b3b7 commit a16d9b5
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 66 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Linters

on:
push:
pull_request:
branches:
# Branches from forks have the form 'user:branch-name' so we only run
# this job on pull_request events for branches that look like fork
# branches. Without this we would end up running this job twice for non
# forked PRs, once for the push and then once for opening the PR.
- "**:**"

jobs:
golangci-lint:
name: Golang-CI (lint)
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Run linter
uses: golangci/golangci-lint-action@v2 # Action page: <https://github.com/golangci/golangci-lint-action>
with:
version: v1.37 # without patch version
only-new-issues: false # show only new issues if it's a pull request
15 changes: 1 addition & 14 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
fail-fast: true
matrix:
php: [ "7.4", "8.0" ]
go: [ "1.14", "1.15" ]
go: [ "1.15", "1.16" ]
os: [ ubuntu-20.04 ]
steps:
- name: Set up Go ${{ matrix.go }}
Expand Down Expand Up @@ -75,16 +75,3 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage-ci/summary.txt
fail_ci_if_error: false

golangci-lint:
name: Golang-CI (lint)
runs-on: ubuntu-20.04
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Run linter
uses: golangci/golangci-lint-action@v2 # Action page: <https://github.com/golangci/golangci-lint-action>
with:
version: v1.35 # without patch version
only-new-issues: false # show only new issues if it's a pull request
33 changes: 2 additions & 31 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,26 @@
run:
skip-files:
- plugins/http/tests/http_test.go
- plugins/http/tests/plugin_test_old.go
- plugins/http/tests/rpc_test_old.go
- plugins/http/tests/config_test.go
- plugins/static/tests/static_plugin_test.go
- plugins/headers/tests/old.go
- "protocol/internal/protocol.pb.go"
linters:
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dogsled
# - dupl
- errcheck
- exhaustive
# - funlen
# - gochecknoinits
# - goconst
- gocritic
- gocyclo
- gofmt
- goimports
- golint
# - gomnd
- goprintffuncname
- gosec
# - gosimple
- govet
- ineffassign
- interfacer
# - lll
- misspell
- nakedret
# - noctx
- nolintlint
- rowserrcheck
- scopelint
Expand All @@ -43,20 +29,5 @@ linters:
- stylecheck
- typecheck
- unconvert
# - unparam
# - unused
- varcheck
- whitespace

# don't enable:
# - asciicheck
# - gochecknoglobals
# - gocognit
# - godot
# - godox
# - goerr113
# - maligned
# - nestif
# - prealloc
# - testpackage
# - wsl
- whitespace
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[![Build status](https://badge.buildkite.com/fc0e676d7bee1a159916af52ebdb541708d4b9f88b8a980f6b.svg?branch=master)](https://buildkite.com/temporal/roadrunner-temporal)
[![Linux](https://github.com/temporalio/roadrunner-temporal/workflows/Linux/badge.svg)](https://github.com/temporalio/roadrunner-temporal/actions)
[![Linters](https://github.com/temporalio/roadrunner-temporal/workflows/Linters/badge.svg)](https://github.com/temporalio/roadrunner-temporal/actions)
[![codecov](https://codecov.io/gh/temporalio/roadrunner-temporal/branch/master/graph/badge.svg?token=i3oU4IKmba)](https://codecov.io/gh/temporalio/roadrunner-temporal)
[![Discourse](https://img.shields.io/static/v1?label=Discourse&message=Get%20Help&color=informational)](https://community.temporal.io)

Expand Down
3 changes: 2 additions & 1 deletion activity/activity_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/spiral/roadrunner/v2/pkg/pool"
rrWorker "github.com/spiral/roadrunner/v2/pkg/worker"
"github.com/spiral/roadrunner/v2/plugins/server"
roadrunner_temporal "github.com/temporalio/roadrunner-temporal"
"github.com/temporalio/roadrunner-temporal/client"
rrt "github.com/temporalio/roadrunner-temporal/protocol"
"github.com/temporalio/roadrunner-temporal/utils"
Expand Down Expand Up @@ -50,7 +51,7 @@ type activityPoolImpl struct {
func newActivityPool(codec rrt.Codec, listener events.Listener, poolConfig pool.Config, server server.Server) (activityPool, error) {
const op = errors.Op("new_activity_pool")
// env variables
env := map[string]string{RR_MODE: RRMode, RR_CODEC: codec.GetName()}
env := map[string]string{RR_MODE: roadrunner_temporal.RRMode, RR_CODEC: codec.GetName()}
wp, err := server.NewWorkerPool(context.Background(), poolConfig, env, listener)
if err != nil {
return nil, errors.E(op, err)
Expand Down
9 changes: 2 additions & 7 deletions activity/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/spiral/roadrunner/v2/pkg/events"
"github.com/spiral/roadrunner/v2/pkg/worker"
"github.com/spiral/roadrunner/v2/plugins/config"
roadrunner_temporal "github.com/temporalio/roadrunner-temporal"

"sync"
"sync/atomic"
Expand All @@ -21,12 +22,6 @@ import (
const (
// PluginName defines public service name.
PluginName = "activities"

// Main plugin name
RootPluginName = "temporal"

// RRMode sets as RR_MODE env variable to let worker know about the mode to run.
RRMode = "temporal"
)

// Plugin to manage activity execution.
Expand All @@ -44,7 +39,7 @@ type Plugin struct {
// Init configures activity service.
func (p *Plugin) Init(temporal client.Temporal, server server.Server, log logger.Logger, cfg config.Configurer) error {
const op = errors.Op("activity_plugin_init")
if !cfg.Has(RootPluginName) {
if !cfg.Has(roadrunner_temporal.RootPluginName) {
return errors.E(op, errors.Disabled)
}

Expand Down
9 changes: 9 additions & 0 deletions constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package roadrunner_temporal //nolint:golint,stylecheck

const (
// Main plugin name
RootPluginName = "temporal"

// RRMode sets as RR_MODE env variable to let worker know about the mode to run.
RRMode = "temporal"
)
6 changes: 3 additions & 3 deletions protocol/proto_codec.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package protocol

import (
v1 "github.com/golang/protobuf/proto" //nolint:staticcheck
v1Proto "github.com/golang/protobuf/proto" //nolint:staticcheck
jsoniter "github.com/json-iterator/go"
"github.com/spiral/errors"
"github.com/spiral/roadrunner/v2/pkg/payload"
Expand Down Expand Up @@ -60,7 +60,7 @@ func (c *ProtoCodec) Execute(e Endpoint, ctx Context, msg ...Message) ([]Message
return nil, errors.E(errors.Op("encodeContext"), err)
}

p.Body, err = proto.Marshal(v1.MessageV2(request))
p.Body, err = proto.Marshal(v1Proto.MessageV2(request))
if err != nil {
return nil, errors.E(errors.Op("encodePayload"), err)
}
Expand All @@ -75,7 +75,7 @@ func (c *ProtoCodec) Execute(e Endpoint, ctx Context, msg ...Message) ([]Message
return nil, nil
}

err = proto.Unmarshal(out.Body, v1.MessageV2(response))
err = proto.Unmarshal(out.Body, v1Proto.MessageV2(response))
if err != nil {
return nil, errors.E(errors.Op("parseResponse"), err)
}
Expand Down
4 changes: 2 additions & 2 deletions tests/src/Workflow/CancelledNestedWorkflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function () {
$this->status[] = 'second scope';

try {
yield Workflow::timer(2);
yield Workflow::timer(20);
} catch (CanceledFailure $e) {
$this->status[] = 'second scope cancelled';
throw $e;
Expand All @@ -46,7 +46,7 @@ function () {
);

try {
yield Workflow::timer(1);
yield Workflow::timer(20);
} catch (CanceledFailure $e) {
$this->status[] = 'first scope cancelled';
throw $e;
Expand Down
9 changes: 2 additions & 7 deletions workflow/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,13 @@ import (
"github.com/spiral/roadrunner/v2/plugins/config"
"github.com/spiral/roadrunner/v2/plugins/logger"
"github.com/spiral/roadrunner/v2/plugins/server"
roadrunner_temporal "github.com/temporalio/roadrunner-temporal"
"github.com/temporalio/roadrunner-temporal/client"
)

const (
// PluginName defines public service name.
PluginName = "workflows"

// Main plugin name
RootPluginName = "temporal"

// RRMode sets as RR_MODE env variable to let pool know about the mode to run.
RRMode = "workflow"
)

// Plugin manages workflows and workers.
Expand All @@ -45,7 +40,7 @@ type Plugin struct {
// Init workflow plugin.
func (p *Plugin) Init(temporal client.Temporal, server server.Server, log logger.Logger, cfg config.Configurer) error {
const op = errors.Op("workflow_plugin_init")
if !cfg.Has(RootPluginName) {
if !cfg.Has(roadrunner_temporal.RootPluginName) {
return errors.E(op, errors.Disabled)
}
p.temporal = temporal
Expand Down
3 changes: 2 additions & 1 deletion workflow/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
rrPool "github.com/spiral/roadrunner/v2/pkg/pool"
rrWorker "github.com/spiral/roadrunner/v2/pkg/worker"
"github.com/spiral/roadrunner/v2/plugins/server"
roadrunner_temporal "github.com/temporalio/roadrunner-temporal"
"github.com/temporalio/roadrunner-temporal/client"
rrt "github.com/temporalio/roadrunner-temporal/protocol"
bindings "go.temporal.io/sdk/internalbindings"
Expand Down Expand Up @@ -48,7 +49,7 @@ type workerImpl struct {
// newPool creates new workflow pool.
func newPool(codec rrt.Codec, factory server.Server, listener ...events.Listener) (pool, error) {
const op = errors.Op("new_workflow_pool")
env := map[string]string{RR_MODE: RRMode, RR_CODEC: codec.GetName()}
env := map[string]string{RR_MODE: roadrunner_temporal.RRMode, RR_CODEC: codec.GetName()}

cfg := rrPool.Config{
NumWorkers: 1,
Expand Down

0 comments on commit a16d9b5

Please sign in to comment.