From ec5c76d0684b41449d2a80fe67fa641a765eba2d Mon Sep 17 00:00:00 2001 From: Marcel Lanz Date: Sun, 15 Nov 2020 21:46:34 +0100 Subject: [PATCH] fix doc links v0.2.1 (#52) * [fix] fix invalid links. * [fix] report err on fatal condition. * [fix] choose new proxy image. --- docs/src/modules/go/pages/crdt.adoc | 6 +++--- docs/src/modules/go/pages/eventsourced.adoc | 10 +++++----- docs/src/modules/go/pages/serialization.adoc | 2 +- tck/run_dev_proxy.sh | 4 ++-- tck/run_dev_proxy_tck.sh | 4 ++-- tck/run_tck.sh | 4 ++-- tck/test/eventsourced/eventsourced_test.go | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/src/modules/go/pages/crdt.adoc b/docs/src/modules/go/pages/crdt.adoc index 29fe094..917a539 100644 --- a/docs/src/modules/go/pages/crdt.adoc +++ b/docs/src/modules/go/pages/crdt.adoc @@ -14,7 +14,7 @@ include::example$cloudstate/crdt/entity.go[tag=entity-handler] == Accessing and creating an entity's CRDT -Each CRDT entity manages one root CRDT. That CRDT will either be supplied to the entity by the proxy when it is started through {cloudstate-go-lib-api-base}/cloudstate/crdt#EntityHandler.Set[`crdt.EntityHandler.Set`], or, if no CRDT exists for the entity when it is started, it has to be created by the entity using the {cloudstate-go-lib-api-base}/cloudstate/crdt#EntityHandler.Default[`crdt.EntityHandler.Default`] factory method. +Each CRDT entity manages one root CRDT. That CRDT will either be supplied to the entity by the proxy when it is started through {cloudstate-go-lib-api-base}/cloudstate/crdt#EntityHandler[`crdt.EntityHandler.Set`], or, if no CRDT exists for the entity when it is started, it has to be created by the entity using the {cloudstate-go-lib-api-base}/cloudstate/crdt#EntityHandler[`crdt.EntityHandler.Default`] factory method. [source,go] ---- @@ -30,7 +30,7 @@ In this regard, a type assertion check is not necessary. == Handling commands -Command handlers are implemented with the {cloudstate-go-lib-api-base}/cloudstate/crdt#EntityHandler.HandleCommand[`crdt.EntityHandler.HandleCommand`] method. +Command handlers are implemented with the {cloudstate-go-lib-api-base}/cloudstate/crdt#EntityHandler[`crdt.EntityHandler.HandleCommand`] method. The command handler provides a `CommandContext`, a commands `name`, and the gRPCs message as a protobuf message. The matching combination of a commands name and the messages type from the defined gRPC service can be used to handle the command. So to handle the shopping cart service method `GetCart`: @@ -115,7 +115,7 @@ include::example$example/crdt_shoppingcart/shoppingcart/entity.go[tag=watch-cart === Ending the stream -The `ChangeFunc` handler function can end the stream by invoking {cloudstate-go-lib-api-base}/cloudstate/crdt#CommandContext.EndStream[`crdt.CommandContext.EndStream`] on the `CommandCOntext` it is passed. +The `ChangeFunc` handler function can end the stream by invoking {cloudstate-go-lib-api-base}/cloudstate/crdt#CommandContext.EndStream[`crdt.CommandContext.EndStream`] on the `CommandContext` it is passed. If it does this, it will not receive an cancellation callback. === Responding to stream cancellation diff --git a/docs/src/modules/go/pages/eventsourced.adoc b/docs/src/modules/go/pages/eventsourced.adoc index e9d8a8b..a0a13b9 100644 --- a/docs/src/modules/go/pages/eventsourced.adoc +++ b/docs/src/modules/go/pages/eventsourced.adoc @@ -12,7 +12,7 @@ An event sourced entity can be created by implementing the {cloudstate-go-lib-ap include::example$cloudstate/eventsourced/entity.go[tag=entity-type] ---- -Then register that entity with {cloudstate-go-lib-api-base}/cloudstate/cloudstate#RegisterEventSourced[`cloudstate.CloudState.RegisterEventSourced`], your entity gets configured to be an event sourced entity and handled by the Cloudstate instance from now on. +Then register that entity with {cloudstate-go-lib-api-base}/cloudstate#CloudState.RegisterEventSourced[`cloudstate.CloudState.RegisterEventSourced`], your entity gets configured to be an event sourced entity and handled by the Cloudstate instance from now on. [source,go] ---- @@ -83,7 +83,7 @@ include::example$example/shoppingcart/entity.go[tag=entity-func] == Handling commands -An event sourced entity implements the {cloudstate-go-lib-api-base}/cloudstate/eventsourced#EntityHandler[`eventsourced.EntityHandler`] interface and there for command handling the {cloudstate-go-lib-api-base}/cloudstate/eventsourced#HandleCommand[`HandleCommand`] method. +An event sourced entity implements the {cloudstate-go-lib-api-base}/cloudstate/eventsourced#EntityHandler[`eventsourced.EntityHandler`] interface and there for command handling the `HandleCommand` method. The command types received by an event sourced entity are declared by the gRPC Server interface which is generated from the protobuf definitions. The Cloudstate Go Support library together with the registered `eventsourced.Entity` is then able to dispatch commands it gets from the Cloudstate proxy. @@ -110,8 +110,8 @@ Commands that modify the state may do so by emitting events. WARNING: The *only* way a command handler may modify its state is by emitting an event. Any modifications made directly to the state from the command handler will not be persisted, and when the entity is passivated and next reloaded, those modifications will not be present. -A command handler may emit an event by using the {cloudstate-go-lib-api-base}/cloudstate/eventsourced#Context[`eventsourced.Context`] and invoking the {cloudstate-go-lib-api-base}/cloudstate/eventsourced#Emit[`Emit`] method on it. -Calling {cloudstate-go-lib-api-base}/cloudstate/eventsourced#Emit[`Emit`] will immediately invoke the associated event handler for that event - this both validates that the event can be applied to the current state, as well as updates the state so that subsequent processing in the command handler can use it. +A command handler may emit an event by using the {cloudstate-go-lib-api-base}/cloudstate/eventsourced#Context[`eventsourced.Context`] and invoking the {cloudstate-go-lib-api-base}/cloudstate/eventsourced#Context.Emit[`Emit`] method on it. +Calling {cloudstate-go-lib-api-base}/cloudstate/eventsourced#Context.Emit[`Emit`] will immediately invoke the associated event handler for that event - this both validates that the event can be applied to the current state, as well as updates the state so that subsequent processing in the command handler can use it. Here's an example of a command handler that emits an event: @@ -129,7 +129,7 @@ Event handlers are invoked at two points, when restoring entities from the journ An event handler's responsibility is to update the state of the entity according to the event. Event handlers are the only place where it's safe to mutate the state of the entity at all. -Every event sourced entity implements the {cloudstate-go-lib-api-base}/cloudstate/eventsourced#EntityHandler[`eventsourced.EntityHandler`]s interface {cloudstate-go-lib-api-base}/cloudstate/eventsourced#HandleEvent[`HandleEvent`] method. +Every event sourced entity implements the {cloudstate-go-lib-api-base}/cloudstate/eventsourced#EntityHandler[`eventsourced.EntityHandler`]s interface `HandleEvent` method. Events emitted by command handlers get dispatched to the implemented event handler which then decides how to proceed with the event. [source,go] diff --git a/docs/src/modules/go/pages/serialization.adoc b/docs/src/modules/go/pages/serialization.adoc index 970336c..f6d94bf 100644 --- a/docs/src/modules/go/pages/serialization.adoc +++ b/docs/src/modules/go/pages/serialization.adoc @@ -47,7 +47,7 @@ The main reason not to support it is, that an `int` is not the same type as an ` == JSON -Cloudstate uses the standard library package https://golang.org/pkg/encoding/json/[`encoding/json`] to serialize JSON. +Cloudstate uses the standard library package https://pkg.go.dev/encoding/json[`encoding/json`] to serialize JSON. Any type that has a field declared with a string literal tag `json:"fieldname"` will be serialized to and from JSON using the https://golang.org/pkg/encoding/json/#Marshal[Marshaller and Unmarshaller] from the Go standard library package `encoding/json`. The details of how these are serialized can be found xref:contribute:serialization.adoc#json-values[here]. diff --git a/tck/run_dev_proxy.sh b/tck/run_dev_proxy.sh index 62d38e4..4e7572f 100755 --- a/tck/run_dev_proxy.sh +++ b/tck/run_dev_proxy.sh @@ -5,13 +5,13 @@ function rnd() { cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1 } -PROXY_IMAGE=${2:-cloudstateio/cloudstate-proxy-dev-mode:latest} +PROXY_IMAGE=${2:-cloudstateio/cloudstate-proxy-core:latest} PROXY="cloudstate-proxy-$(rnd)" set -x # run the proxy docker run --rm --name "$PROXY" -p 9000:9000 -e USER_FUNCTION_HOST=host.docker.internal -e USER_FUNCTION_PORT=8090 \ - "${PROXY_IMAGE}" -Dcloudstate.proxy.passivation-timeout=30s || exit $? + "${PROXY_IMAGE}" -Dcloudstate.proxy.passivation-timeout=30s -Dconfig.resource=dev-mode.conf || exit $? tck_status=$? exit $tck_status diff --git a/tck/run_dev_proxy_tck.sh b/tck/run_dev_proxy_tck.sh index aab0b0f..274127f 100755 --- a/tck/run_dev_proxy_tck.sh +++ b/tck/run_dev_proxy_tck.sh @@ -5,7 +5,7 @@ function rnd() { cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1 } -PROXY_IMAGE=${2:-cloudstateio/cloudstate-proxy-dev-mode:latest} +PROXY_IMAGE=${2:-cloudstateio/cloudstate-proxy-core:latest} PROXY="cloudstate-proxy-$(rnd)" TCK_IMAGE=${3:-cloudstateio/cloudstate-tck:latest} TCK="cloudstate-tck-$(rnd)" @@ -16,7 +16,7 @@ finally() { trap finally EXIT set -x -docker run -d --name "$PROXY" -p 9000:9000 -e USER_FUNCTION_HOST=host.docker.internal -e USER_FUNCTION_PORT=8090 "${PROXY_IMAGE}" || exit $? +docker run -d --name "$PROXY" -p 9000:9000 -e USER_FUNCTION_HOST=host.docker.internal -e USER_FUNCTION_PORT=8090 "${PROXY_IMAGE}" -Dconfig.resource=dev-mode.conf || exit $? docker run --rm --name cloudstate-tck -p 8090:8090 -e TCK_HOST=0.0.0.0 -e TCK_PROXY_HOST=host.docker.internal -e TCK_SERVICE_HOST=host.docker.internal "${TCK_IMAGE}" tck_status=$? diff --git a/tck/run_tck.sh b/tck/run_tck.sh index 273e8eb..aeb551a 100755 --- a/tck/run_tck.sh +++ b/tck/run_tck.sh @@ -7,7 +7,7 @@ function rnd() { FUNC_IMAGE=${1:-cloudstateio/cloudstate-go-tck:latest} FUNC="cloudstate-function-$(rnd)" -PROXY_IMAGE=${2:-cloudstateio/cloudstate-proxy-dev-mode:latest} +PROXY_IMAGE=${2:-cloudstateio/cloudstate-proxy-core:latest} PROXY="cloudstate-proxy-$(rnd)" TCK_IMAGE=${3:-cloudstateio/cloudstate-tck:latest} TCK="cloudstate-tck-$(rnd)" @@ -21,7 +21,7 @@ set -x # run the function and the proxy docker run -d --name "$FUNC" --net=host "${FUNC_IMAGE}" || exit $? -docker run -d --name "$PROXY" --net=host -e USER_FUNCTION_PORT=8090 "${PROXY_IMAGE}" || exit $? +docker run -d --name "$PROXY" --net=host -e USER_FUNCTION_PORT=8090 "${PROXY_IMAGE}" -Dconfig.resource=dev-mode.conf || exit $? # run the tck docker run --rm --name $TCK --net=host "${TCK_IMAGE}" diff --git a/tck/test/eventsourced/eventsourced_test.go b/tck/test/eventsourced/eventsourced_test.go index 248206e..37061e9 100644 --- a/tck/test/eventsourced/eventsourced_test.go +++ b/tck/test/eventsourced/eventsourced_test.go @@ -243,7 +243,7 @@ func TestEventsourcingShoppingCart(t *testing.T) { t.Fatal(errors.New("expected error")) } if err != io.EOF { - t.Fatal(errors.New("expected io.EOF error")) + t.Fatalf("expected io.EOF error but got: %v", err) } })