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

Commit

Permalink
fix doc links v0.2.1 (#52)
Browse files Browse the repository at this point in the history
* [fix] fix invalid links.
* [fix] report err on fatal condition.
* [fix] choose new proxy image.
  • Loading branch information
marcellanz authored Nov 15, 2020
1 parent 4be8b76 commit ec5c76d
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions docs/src/modules/go/pages/crdt.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
----
Expand All @@ -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`:
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions docs/src/modules/go/pages/eventsourced.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
----
Expand Down Expand Up @@ -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.

Expand All @@ -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:

Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/go/pages/serialization.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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].
Expand Down
4 changes: 2 additions & 2 deletions tck/run_dev_proxy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions tck/run_dev_proxy_tck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand All @@ -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=$?

Expand Down
4 changes: 2 additions & 2 deletions tck/run_tck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand All @@ -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}"
Expand Down
2 changes: 1 addition & 1 deletion tck/test/eventsourced/eventsourced_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})

Expand Down

0 comments on commit ec5c76d

Please sign in to comment.