Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

feature/go-support #103

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f00c69e
[go-support] made TCK test #1 happy... very raw but some circles clos…
marcellanz Aug 31, 2019
3c8dea7
[go-support] EntityDiscoveryManager happy with the EntitySpec it gets…
marcellanz Aug 31, 2019
5ca9a02
[go-support] shopping cart implemented. TCK nearly green (lacking: ev…
marcellanz Sep 5, 2019
6d7af6f
[go-support] TCK 100% passed having the shopping cart example impleme…
marcellanz Sep 8, 2019
879d93b
[go-support] return errors instead of panic
marcellanz Sep 8, 2019
336d4d4
[go-support] having the shopping cart in a separate package. travis b…
marcellanz Sep 8, 2019
9d28e64
[go-support] build go support solely in travis TCK run
marcellanz Sep 8, 2019
ec0b7cc
[go-support] added copyright
marcellanz Sep 8, 2019
d0fc04d
[go-support] refactored from PoC to a CloudState Go Client API implem…
marcellanz Sep 13, 2019
9e0a8dd
[go-support] fix go test and TCK on travis
marcellanz Sep 13, 2019
017fed6
[go-support] apply CodeReviewComments#indent-error-flow best practice…
marcellanz Sep 13, 2019
f7409c0
[go-support] removed logging
marcellanz Sep 13, 2019
ee52ef5
[go-support] fixes from my own code review :-), applying some of Go's…
marcellanz Sep 13, 2019
4b220df
[go-support] removed main.go, README cleanup
marcellanz Sep 13, 2019
da7d4fe
[go-support] changes from my own code review
marcellanz Sep 13, 2019
744c790
[go-support] having a sbt task to build the go shopping cart binary w…
marcellanz Sep 15, 2019
360e379
[go-support] the PoC is removed
marcellanz Sep 15, 2019
e5ef360
[go-support] refactored the filedescriptor registration, more documen…
marcellanz Sep 15, 2019
19bcebb
[go-support] fix copy paste error
marcellanz Sep 15, 2019
ece6c1e
[go-support] "Errorf format %w has unknown verb w" => lets go with go…
marcellanz Sep 15, 2019
dbd08e5
[go-support] fix refactoring bug. let the TCK report the config.name …
marcellanz Sep 15, 2019
29f3d4a
[go-support] fix travis build
marcellanz Sep 15, 2019
c99b53d
[go-support] EventSourcedHandler#handleEvents tries to find now a fit…
marcellanz Sep 16, 2019
4076d10
[go-support] *.proto files and .pb.go files removed
marcellanz Sep 16, 2019
69fb515
[go-support] generate *.pb.go on the fly. move generate script to ./b…
marcellanz Sep 16, 2019
26d10af
[go-support] compile protocol buffers with travis build
marcellanz Sep 17, 2019
a48158a
[go-support] having protocol buffers compilation on travis
marcellanz Sep 17, 2019
eea762d
[go-support] fix .travis.yml by adding missing shell command
marcellanz Sep 17, 2019
f38145e
Merge remote-tracking branch 'upstream/master' into feature/go-support
marcellanz Sep 17, 2019
ed14794
Merge remote-tracking branch 'upstream/master' into feature/go-support
marcellanz Sep 18, 2019
7f9288b
[go-support] documentation for go-support
marcellanz Sep 18, 2019
46506e4
[go-support] added one TODO and moved a comment
marcellanz Sep 18, 2019
0994ad3
[go-support, cherry-picked from √] Hooking the Go compilation step in…
viktorklang Sep 16, 2019
ba47ee0
[go-support, cherry-picked from √] ran sbt scalafmtSbt
marcellanz Sep 18, 2019
8cfc8b8
[go-support, PR#103] cleaned up fatals, replaced with errors. recover…
marcellanz Sep 20, 2019
c1afd6a
[go-support] added prebuild script, let protoc be built, added script…
marcellanz Sep 21, 2019
2deb37a
[go-support] added tests
marcellanz Sep 26, 2019
677151a
Merge remote-tracking branch 'upstream/master' into feature/go-suppor…
marcellanz Sep 26, 2019
2bdc3b7
[go-support] build tck with -race flag enabled
marcellanz Sep 26, 2019
35e57ae
[go-support] enabled CGO for the -race flag
marcellanz Sep 26, 2019
ee725d5
[go-support] for every call of Emit the emitted event is handled imme…
marcellanz Sep 26, 2019
31faefd
[go-support] improve tests (capture output of some, enable verbose mo…
marcellanz Sep 27, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,10 @@ jobs:
script: sbt 'set concurrentRestrictions in Global += Tags.limitAll(1)' test

- name: go tests
install:
- curl -L https://github.com/google/protobuf/releases/download/v3.9.1/protoc-3.9.1-linux-x86_64.zip -o /tmp/protoc-3.9.1-linux-x86_64.zip
- unzip /tmp/protoc-3.9.1-linux-x86_64.zip -d "$HOME"/protoc
- eval "$(gimme 1.13)" && go env
- go get -u github.com/golang/protobuf/protoc-gen-go
env:
- PATH=$HOME/protoc/bin:$PATH
before_script:
- go version
- ./go-support/build/prebuild_go-support_in_docker.sh
script:
- cd go-support/ && ./build/compile_protobufs.sh && go test -count=1 ./... && cd -
- cd go-support && ./build/run_go_test_in_docker.sh && cd -

- name: docs tests
before_script:
Expand All @@ -57,14 +50,7 @@ jobs:
- sbt update
- cd node-support && npm install && cd -
- cd samples/js-shopping-cart && npm install && cd -
# these lines will be removed once revised task of
# buildGoTCKShoppingCart by @viktorklang will be merged (5b9df7c20b1da194d209f7a44b2bc29bdc601cd0)
# and the go build is done by the Go Docker container
- curl -L https://github.com/google/protobuf/releases/download/v3.9.1/protoc-3.9.1-linux-x86_64.zip -o /tmp/protoc-3.9.1-linux-x86_64.zip
- unzip /tmp/protoc-3.9.1-linux-x86_64.zip -d "$HOME"/protoc
- eval "$(gimme 1.13)" && go env
- go get -u github.com/golang/protobuf/protoc-gen-go
- pushd . && cd go-support && PATH=$HOME/protoc/bin:$PATH ./build/compile_protobufs.sh && cd shoppingcart/cmd/shoppingcart && CGO_ENABLED=0 go build -o tck_shoppingcart && popd
- sbt go-support/compile
script:
- sbt 'set concurrentRestrictions in Global += Tags.limitAll(1)' tck/it:test

Expand Down
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -674,9 +674,9 @@ lazy val `go-support` = (project in file("go-support"))

val SuccessMessage = "go-support compiled successfully: " + os_arch + "\n"

(cmd !!) match {
case SuccessMessage =>
streams.value.log.success("go-support compilation succeeded")
(cmd !) match {
case 0 =>
streams.value.log.success(SuccessMessage)
(compile in Compile).value // TODO should we produce our own compilation result instead perhaps?
case err =>
throw new IllegalStateException("go-support compilation failed: " + err)
Expand Down
8 changes: 7 additions & 1 deletion go-support/build/build_tck_shopping_cart_in_docker.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
#!/usr/bin/env bash

set -o nounset
set -o errexit
set -o pipefail

SUFFIX=""
if [ "$GOOS" == "windows" ]; then
SUFFIX=".exe"
fi

cd shoppingcart/cmd/shoppingcart/ && CGO_ENABLED=0 go build -v -o "tck_shoppingcart${SUFFIX}" && echo "go-support compiled successfully: ${GOOS} on ${GOARCH}"
./go-support/build/prebuild_go-support_in_docker.sh
cd go-support/shoppingcart/cmd/shoppingcart/
CGO_ENABLED=0 go build -v -o "tck_shoppingcart${SUFFIX}" && echo "go-support compiled successfully: ${GOOS} on ${GOARCH}"
4 changes: 4 additions & 0 deletions go-support/build/compile_protobufs.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env bash

set -o nounset
set -o errexit
set -o pipefail

cp -a ../protocols protos

protoc --go_out=plugins=grpc:. --proto_path=./protos/frontend/ --proto_path=./protos/protocol/ --proto_path=./protos/proxy/ --proto_path=./protos/example/ protos/protocol/cloudstate/entity.proto
Expand Down
12 changes: 12 additions & 0 deletions go-support/build/prebuild_go-support_in_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -e

apt-get update -y && apt-get install unzip -y
curl -L https://github.com/google/protobuf/releases/download/v3.9.1/protoc-3.9.1-linux-x86_64.zip -o /tmp/protoc-3.9.1-linux-x86_64.zip
unzip /tmp/protoc-3.9.1-linux-x86_64.zip -d "$HOME"/protoc
# set GOOS and GOARCH to host values for this one line as protoc-gen-go has to be compiled.
GOOS=linux GOARCH=amd64 go get -u github.com/golang/protobuf/protoc-gen-go

cd go-support
PATH=$HOME/protoc/bin:/$GOPATH/bin:$PATH ./build/compile_protobufs.sh
7 changes: 7 additions & 0 deletions go-support/build/run_go_test_in_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -o nounset
set -o errexit
set -o pipefail

docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp golang:1.13 go test -count 1 -race ./...
3 changes: 2 additions & 1 deletion go-support/build/run_tck_shopping_cart_build.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<#
TODO: write the equivalence of the script build/run_tck_shopping_cart_build.sh
#>
Write-Host "someone with windows has to write this script"
Write-Host "someone with windows has to write this script"
Exit 1
7 changes: 5 additions & 2 deletions go-support/build/run_tck_shopping_cart_build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env bash

cd go-support
set -o nounset
set -o errexit
set -o pipefail

docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp -e GOOS=${1} -e GOARCH=${2} \
golang:1.13 ./build/build_tck_shopping_cart_in_docker.sh
golang:1.13 ./go-support/build/build_tck_shopping_cart_in_docker.sh
16 changes: 10 additions & 6 deletions go-support/cloudstate/cloudstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,24 @@ func (cs *CloudState) Register(ese *EventSourcedEntity, config DescriptorConfig)
}

// Run runs the CloudState instance.
func (cs *CloudState) Run() {
func (cs *CloudState) Run() error {
host, ok := os.LookupEnv("HOST")
if !ok {
log.Fatalf("unable to get environment variable \"HOST\"")
return fmt.Errorf("unable to get environment variable \"HOST\"")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much more meaningful response here, and elsewhere in your latest update 👍

}
port, ok := os.LookupEnv("PORT")
if !ok {
log.Fatalf("unable to get environment variable \"PORT\"")
return fmt.Errorf("unable to get environment variable \"PORT\"")
}
lis, err := net.Listen("tcp", fmt.Sprintf("%s:%s", host, port))
if err != nil {
log.Fatalf("failed to listen: %v\n", err)
return fmt.Errorf("failed to listen: %v\n", err)
}
log.Printf("starting grpcServer at: %s:%s", host, port)
if e := cs.server.Serve(lis); e != nil {
log.Fatalf("failed to grpcServer.Serve for: %v", lis)
return fmt.Errorf("failed to grpcServer.Serve for: %v", lis)
}
return nil
}

// EntityDiscoveryResponder implements the CloudState discovery protocol.
Expand Down Expand Up @@ -240,7 +241,10 @@ func (r *EntityDiscoveryResponder) registerFileDescriptorProto(filename string)
}

func (r *EntityDiscoveryResponder) registerFileDescriptor(msg descriptor.Message) error {
fd, _ := descriptor.ForMessage(msg) // this can panic, so we do here
fd, _ := descriptor.ForMessage(msg) // this can panic
if r := recover(); r != nil {
return fmt.Errorf("descriptor.ForMessage panicked (%v) for: %+v", r, msg)
}
r.fileDescriptorSet.File = append(r.fileDescriptorSet.File, fd)
return nil
}
Loading