Skip to content

Commit

Permalink
Fix broken links (#143)
Browse files Browse the repository at this point in the history
* fix broken links

* fixed docs links for src

* cleanup docs src links

* fixed in docs links

* Update docs/content/pubsubs/sql.md

Co-Authored-By: Miłosz Smółka <[email protected]>
  • Loading branch information
roblaszczak and m110 authored Sep 24, 2019
1 parent f5ffd63 commit 5a4ba70
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 54 deletions.
26 changes: 13 additions & 13 deletions docs/content/docs/cqrs.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ The command is a simple data structure, representing the request for executing s
#### Command Bus

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/components/cqrs/command_bus.go" first_line_contains="// CommandBus" last_line_contains="type CommandBus" padding_after="0" %}}
{{% load-snippet-partial file="src-link/components/cqrs/command_bus.go" first_line_contains="// CommandBus" last_line_contains="type CommandBus" padding_after="0" %}}
{{% /render-md %}}

#### Command Processor

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/components/cqrs/command_processor.go" first_line_contains="// CommandProcessor" last_line_contains="type CommandProcessor" padding_after="0" %}}
{{% load-snippet-partial file="src-link/components/cqrs/command_processor.go" first_line_contains="// CommandProcessor" last_line_contains="type CommandProcessor" padding_after="0" %}}
{{% /render-md %}}

#### Command Handler

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/components/cqrs/command_processor.go" first_line_contains="// CommandHandler" last_line_contains="type CommandHandler" padding_after="0" %}}
{{% load-snippet-partial file="src-link/components/cqrs/command_processor.go" first_line_contains="// CommandHandler" last_line_contains="type CommandHandler" padding_after="0" %}}
{{% /render-md %}}

#### Event
Expand All @@ -49,31 +49,31 @@ The event represents something that already took place. Events are immutable.
#### Event Bus

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/components/cqrs/event_bus.go" first_line_contains="// EventBus" last_line_contains="type EventBus" padding_after="0" %}}
{{% load-snippet-partial file="src-link/components/cqrs/event_bus.go" first_line_contains="// EventBus" last_line_contains="type EventBus" padding_after="0" %}}
{{% /render-md %}}

#### Event Processor

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/components/cqrs/event_processor.go" first_line_contains="// EventProcessor" last_line_contains="type EventProcessor" padding_after="0" %}}
{{% load-snippet-partial file="src-link/components/cqrs/event_processor.go" first_line_contains="// EventProcessor" last_line_contains="type EventProcessor" padding_after="0" %}}
{{% /render-md %}}

#### Event Handler

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/components/cqrs/event_processor.go" first_line_contains="// EventHandler" last_line_contains="type EventHandler" padding_after="0" %}}
{{% load-snippet-partial file="src-link/components/cqrs/event_processor.go" first_line_contains="// EventHandler" last_line_contains="type EventHandler" padding_after="0" %}}
{{% /render-md %}}

#### CQRS Facade

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/components/cqrs/cqrs.go" first_line_contains="// Facade" last_line_contains="type Facade" padding_after="0" %}}
{{% load-snippet-partial file="src-link/components/cqrs/cqrs.go" first_line_contains="// Facade" last_line_contains="type Facade" padding_after="0" %}}
{{% /render-md %}}

#### Command and Event Marshaler

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/components/cqrs/marshaler.go" first_line_contains="// CommandEventMarshaler" last_line_contains="NameFromMessage(" padding_after="1" %}}
{{% load-snippet-partial file="src-link/components/cqrs/marshaler.go" first_line_contains="// CommandEventMarshaler" last_line_contains="NameFromMessage(" padding_after="1" %}}
{{% /render-md %}}

## Usage
Expand Down Expand Up @@ -107,23 +107,23 @@ The domain is simple:
For the beginning, we need to simulate the guest's action.

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/_examples/basic/5-cqrs-protobuf/main.go" first_line_contains="bookRoomCmd := &BookRoom{" last_line_contains="panic(err)" padding_after="1" %}}
{{% load-snippet-partial file="src-link/_examples/basic/5-cqrs-protobuf/main.go" first_line_contains="bookRoomCmd := &BookRoom{" last_line_contains="panic(err)" padding_after="1" %}}
{{% /render-md %}}

### Command handler

`BookRoomHandler` will handle our command.

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/_examples/basic/5-cqrs-protobuf/main.go" first_line_contains="// BookRoomHandler is a command handler" last_line_contains="// OrderBeerOnRoomBooked is a event handler" padding_after="0" %}}
{{% load-snippet-partial file="src-link/_examples/basic/5-cqrs-protobuf/main.go" first_line_contains="// BookRoomHandler is a command handler" last_line_contains="// OrderBeerOnRoomBooked is a event handler" padding_after="0" %}}
{{% /render-md %}}

### Event handler

As mentioned before, we want to order a beer every time when a room is booked (*"Whenever a Room is booked"* post-it). We do it by using the `OrderBeer` command.

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/_examples/basic/5-cqrs-protobuf/main.go" first_line_contains="// OrderBeerOnRoomBooked is a event handler" last_line_contains="// OrderBeerHandler is a command handler" padding_after="0" %}}
{{% load-snippet-partial file="src-link/_examples/basic/5-cqrs-protobuf/main.go" first_line_contains="// OrderBeerOnRoomBooked is a event handler" last_line_contains="// OrderBeerHandler is a command handler" padding_after="0" %}}
{{% /render-md %}}

`OrderBeerHandler` is very similar to `BookRoomHandler`. The only difference is, that it sometimes returns an error when there are not enough beers, which causes redelivery of the command.
Expand All @@ -132,7 +132,7 @@ You can find the entire implementation in the [example source code](https://gith
### Building a read model with the event handler

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/_examples/basic/5-cqrs-protobuf/main.go" first_line_contains="// BookingsFinancialReport is a read model" last_line_contains="func main() {" padding_after="0" %}}
{{% load-snippet-partial file="src-link/_examples/basic/5-cqrs-protobuf/main.go" first_line_contains="// BookingsFinancialReport is a read model" last_line_contains="func main() {" padding_after="0" %}}
{{% /render-md %}}

### Wiring it up - the CQRS facade
Expand All @@ -148,7 +148,7 @@ Let's go back to the CQRS. As you already know, CQRS is built from multiple comp
To simplify creating all these building blocks, we created `cqrs.Facade`, which creates all of them.

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/_examples/basic/5-cqrs-protobuf/main.go" first_line_contains="main() {" last_line_contains="err := router.Run(" padding_after="3" %}}
{{% load-snippet-partial file="src-link/_examples/basic/5-cqrs-protobuf/main.go" first_line_contains="main() {" last_line_contains="err := router.Run(" padding_after="3" %}}
{{% /render-md %}}

And that's all. We have a working CQRS application.
Expand Down
4 changes: 2 additions & 2 deletions docs/content/docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ The second option is useful when your handler requires some dependencies like da

You can run this example by `go run main.go`.

You've just created your first application with Watermill. You can find the full source in [/docs/src-link/_examples/basic/3-router/main.go](https://github.com/ThreeDotsLabs/watermill/blob/master/docs/src-link/_examples/basic/3-router/main.go).
You've just created your first application with Watermill. You can find the full source in [/_examples/basic/3-router/main.go](https://github.com/ThreeDotsLabs/watermill/blob/master/_examples/basic/3-router/main.go).

### Logging

Expand All @@ -337,7 +337,7 @@ For more detailed documentation check [documentation topics]({{< ref "/docs" >}}

Check out the [examples](https://github.com/ThreeDotsLabs/watermill/tree/master/_examples) that will show you how to start using Watermill.

The recommended entry point is [Your first Watermill application](https://github.com/ThreeDotsLabs/watermill/tree/master/_examples/basic/1-your-first-app).
The recommended entry point is [Your first Watermill application](https://github.com/ThreeDotsLabs/watermill/tree/master/_examples/basic/1-your-first-app).
It contains the entire environment in `docker-compose.yml`, including Golang and Kafka, which you can run with one command.

After that, you can see the [Realtime feed](https://github.com/ThreeDotsLabs/watermill/tree/master/_examples/basic/2-realtime-feed) example.
Expand Down
10 changes: 5 additions & 5 deletions docs/content/docs/message.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,28 @@ When a message is processed, you should send an [`Ack()`]({{< ref "#ack" >}}) or
`Acks` and `Nacks` are processed by Subscribers (in default implementations, the subscribers are waiting for an `Ack` or a `Nack`).

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/message/message.go" first_line_contains="type Message struct {" last_line_contains="ctx context.Context" padding_after="2" %}}
{{% load-snippet-partial file="src-link/message/message.go" first_line_contains="type Message struct {" last_line_contains="ctx context.Context" padding_after="2" %}}
{{% /render-md %}}

### Ack

#### Sending `Ack`

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/message/message.go" first_line_contains="// Ack" last_line_contains="func (m *Message) Ack() bool {" padding_after="0" %}}
{{% load-snippet-partial file="src-link/message/message.go" first_line_contains="// Ack" last_line_contains="func (m *Message) Ack() bool {" padding_after="0" %}}
{{% /render-md %}}


### Nack

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/message/message.go" first_line_contains="// Nack" last_line_contains="func (m *Message) Nack() bool {" padding_after="0" %}}
{{% load-snippet-partial file="src-link/message/message.go" first_line_contains="// Nack" last_line_contains="func (m *Message) Nack() bool {" padding_after="0" %}}
{{% /render-md %}}

### Receiving `Ack/Nack`

{{% render-md %}}
{{% load-snippet-partial file="content/docs/message/receiving-ack.go" first_line_contains="select {" last_line_contains="}" padding_after="0" %}}
{{% load-snippet-partial file="docs/message/receiving-ack.go" first_line_contains="select {" last_line_contains="}" padding_after="0" %}}
{{% /render-md %}}


Expand All @@ -46,6 +46,6 @@ When a message is processed, you should send an [`Ack()`]({{< ref "#ack" >}}) or
Message contains the standard library context, just like an HTTP request.

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/message/message.go" first_line_contains="// Context" last_line_contains="func (m *Message) SetContext" padding_after="2" %}}
{{% load-snippet-partial file="src-link/message/message.go" first_line_contains="// Context" last_line_contains="func (m *Message) SetContext" padding_after="2" %}}
{{% /render-md %}}

16 changes: 8 additions & 8 deletions docs/content/docs/messages-router.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@ To handle these requirements, there is a component named **Router**.
### Configuration

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/message/router.go" first_line_contains="type RouterConfig struct {" last_line_contains="RouterConfig) Validate()" padding_after="2" %}}
{{% load-snippet-partial file="src-link/message/router.go" first_line_contains="type RouterConfig struct {" last_line_contains="RouterConfig) Validate()" padding_after="2" %}}
{{% /render-md %}}

### Handler

At the beginning you need to implement `HandlerFunc`:

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/message/router.go" first_line_contains="// HandlerFunc is" last_line_contains="type HandlerFunc func" padding_after="1" %}}
{{% load-snippet-partial file="src-link/message/router.go" first_line_contains="// HandlerFunc is" last_line_contains="type HandlerFunc func" padding_after="1" %}}
{{% /render-md %}}

Next, you have to add a new handler with `Router.AddHandler`:

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/message/router.go" first_line_contains="// AddHandler" last_line_contains=") {" padding_after="0" %}}
{{% load-snippet-partial file="src-link/message/router.go" first_line_contains="// AddHandler" last_line_contains=") {" padding_after="0" %}}
{{% /render-md %}}

See an example usage from [Getting Started]({{< ref "/docs/getting-started#using-messages-router" >}}):
Expand All @@ -47,7 +47,7 @@ See an example usage from [Getting Started]({{< ref "/docs/getting-started#using
Not every handler will produce new messages. You can add this kind of handler by using `Router.AddNoPublisherHandler`:

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/message/router.go" first_line_contains="// AddNoPublisherHandler" last_line_contains=") {" padding_after="0" %}}
{{% load-snippet-partial file="src-link/message/router.go" first_line_contains="// AddNoPublisherHandler" last_line_contains=") {" padding_after="0" %}}
{{% /render-md %}}

### Ack
Expand All @@ -66,15 +66,15 @@ If it is an issue, consider publishing just one message with each handler.
To run the Router, you need to call `Run()`.

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/message/router.go" first_line_contains="// Run" last_line_contains="func (r *Router) Run(ctx context.Context) (err error) {" padding_after="0" %}}
{{% load-snippet-partial file="src-link/message/router.go" first_line_contains="// Run" last_line_contains="func (r *Router) Run(ctx context.Context) (err error) {" padding_after="0" %}}
{{% /render-md %}}

#### Ensuring that the Router is running

It can be useful to know if the router is running. You can use the `Running()` method for this.

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/message/router.go" first_line_contains="// Running" last_line_contains="func (r *Router) Running()" padding_after="0" %}}
{{% load-snippet-partial file="src-link/message/router.go" first_line_contains="// Running" last_line_contains="func (r *Router) Running()" padding_after="0" %}}
{{% /render-md %}}

### Execution models
Expand All @@ -92,15 +92,15 @@ See the chosen Pub/Sub documentation for supported execution models.
### Middleware

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/message/router.go" first_line_contains="// HandlerMiddleware" last_line_contains="type HandlerMiddleware" padding_after="1" %}}
{{% load-snippet-partial file="src-link/message/router.go" first_line_contains="// HandlerMiddleware" last_line_contains="type HandlerMiddleware" padding_after="1" %}}
{{% /render-md %}}

A full list of standard middlewares can be found in [Middlewares]({{< ref "/docs/middlewares" >}}).

### Plugin

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/message/router.go" first_line_contains="// RouterPlugin" last_line_contains="type RouterPlugin" padding_after="1" %}}
{{% load-snippet-partial file="src-link/message/router.go" first_line_contains="// RouterPlugin" last_line_contains="type RouterPlugin" padding_after="1" %}}
{{% /render-md %}}

A full list of standard plugins can be found in [message/router/plugin](https://github.com/ThreeDotsLabs/watermill/tree/master/message/router/plugin).
14 changes: 7 additions & 7 deletions docs/content/docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@ We provide a default implementation using Prometheus, based on the official [Pro
The `components/metrics` package exports `PrometheusMetricsBuilder`, which provides convenience functions to wrap publishers, subscribers and handlers so that they update the relevant Prometheus registry:

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/components/metrics/builder.go" first_line_contains="// PrometheusMetricsBuilder" last_line_contains="func (b PrometheusMetricsBuilder)" %}}
{{% load-snippet-partial file="src-link/components/metrics/builder.go" first_line_contains="// PrometheusMetricsBuilder" last_line_contains="func (b PrometheusMetricsBuilder)" %}}
{{% /render-md %}}

### Wrapping publishers, subscribers and handlers

If you are using Watermill's [router](/docs/messages-router) (which is recommended in most cases), you can use a single convenience function `AddPrometheusRouterMetrics` to ensure that all the handlers added to this router are wrapped to update the Prometheus registry, together with their publishers and subscribers:

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/components/metrics/builder.go" first_line_contains="// AddPrometheusRouterMetrics" last_line_contains="AddMiddleware" padding_after="1" %}}
{{% load-snippet-partial file="src-link/components/metrics/builder.go" first_line_contains="// AddPrometheusRouterMetrics" last_line_contains="AddMiddleware" padding_after="1" %}}
{{% /render-md %}}

Example use of `AddPrometheusRouterMetrics`:

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/_examples/basic/4-metrics/main.go" first_line_contains="// we leave the namespace" last_line_contains="metricsBuilder.AddPrometheusRouterMetrics" %}}
{{% load-snippet-partial file="src-link/_examples/basic/4-metrics/main.go" first_line_contains="// we leave the namespace" last_line_contains="metricsBuilder.AddPrometheusRouterMetrics" %}}
{{% /render-md %}}

In the snippet above, we have left the `namespace` and `subsystem` arguments empty. The Prometheus client library [uses these](https://godoc.org/github.com/prometheus/client_golang/prometheus#BuildFQName) to prefix the metric names. You may want to use namespace or subsystem, but be aware that this will impact the metric names and you will have to adjust the Grafana dashboard accordingly.

Standalone publishers and subscribers may also be decorated through the use of dedicated methods of `PrometheusMetricBuilder`:

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/_examples/basic/4-metrics/main.go" first_line_contains="subWithMetrics, err := " last_line_contains="pubWithMetrics, err := " padding_after="3" %}}
{{% load-snippet-partial file="src-link/_examples/basic/4-metrics/main.go" first_line_contains="subWithMetrics, err := " last_line_contains="pubWithMetrics, err := " padding_after="3" %}}
{{% /render-md %}}

### Exposing the /metrics endpoint
Expand All @@ -48,13 +48,13 @@ In accordance with how Prometheus works, the service needs to expose a HTTP endp
To serve this endpoint, there are two convenience functions, one using a previously created Prometheus Registry, while the other also creates a new registry:

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/components/metrics/http.go" first_line_contains="// CreateRegistryAndServeHTTP" last_line_contains="func ServeHTTP(" %}}
{{% load-snippet-partial file="src-link/components/metrics/http.go" first_line_contains="// CreateRegistryAndServeHTTP" last_line_contains="func ServeHTTP(" %}}
{{% /render-md %}}

Here is an example of its use in practice:

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/_examples/basic/4-metrics/main.go" first_line_contains="prometheusRegistry, closeMetricsServer :=" last_line_contains="metricsBuilder.AddPrometheusRouterMetrics" %}}
{{% load-snippet-partial file="src-link/_examples/basic/4-metrics/main.go" first_line_contains="prometheusRegistry, closeMetricsServer :=" last_line_contains="metricsBuilder.AddPrometheusRouterMetrics" %}}
{{% /render-md %}}

### Example application
Expand Down Expand Up @@ -142,7 +142,7 @@ If you feel like some metric is missing, you can easily expand this basic implem
An elegant way to update these metrics would be through the use of decorators:

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/message/decorator.go" first_line_contains="// MessageTransformSubscriberDecorator" last_line_contains="type messageTransformSubscriberDecorator" %}}
{{% load-snippet-partial file="src-link/message/decorator.go" first_line_contains="// MessageTransformSubscriberDecorator" last_line_contains="type messageTransformSubscriberDecorator" %}}
{{% /render-md %}}

and/or [router middlewares](/docs/messages-router/#middleware).
Expand Down
2 changes: 1 addition & 1 deletion docs/content/docs/middlewares.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ and capturing the stacktrace.
Middlewares wrap the handler function like this:

{{% render-md %}}
{{% load-snippet-partial file="content/src-link/message/router.go" first_line_contains="// HandlerMiddleware" last_line_contains="type HandlerMiddleware" %}}
{{% load-snippet-partial file="src-link/message/router.go" first_line_contains="// HandlerMiddleware" last_line_contains="type HandlerMiddleware" %}}
{{% /render-md %}}

## Available middlewares
Expand Down
Loading

0 comments on commit 5a4ba70

Please sign in to comment.