snapshot of https://github.com/ThreeDotsLabs/watermill.git (master, 2026-09-15; blobs > 131072B omitted)
Some checks failed
master / ci (push) Failing after 0s

This commit is contained in:
upstream-mirror
2026-09-15 21:27:46 +05:00
commit ce933d1277
538 changed files with 46504 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
+++
title = "FanOut (multiplying messages)"
description = "FanOut is a component that receives messages from the subscriber and passes them to all publishers."
date = 2024-10-09T02:47:30+01:00
weight = -50
draft = false
bref = "FanOut is a component that receives messages from the subscriber and passes them to all publishers."
+++
## FanOut component
FanOut is a component that receives messages from a topic and passes them to all subscribers. In effect, messages are "multiplied".
A typical use case for using FanOut is having one external subscription and multiple workers
inside the process.
### Configuring
{{% load-snippet-partial file="src-link/pubsub/gochannel/fanout.go" first_line_contains="// NewFanOut" last_line_contains=")" padding_after="0" %}}
You need to call AddSubscription method for all topics that you want to listen to.
This needs to be done *before* starting the FanOut.
{{% load-snippet-partial file="src-link/pubsub/gochannel/fanout.go" first_line_contains="// AddSubscription" last_line_contains=")" padding_after="0" %}}
### Running
{{% load-snippet-partial file="src-link/pubsub/gochannel/fanout.go" first_line_contains="// Run" last_line_contains=")" padding_after="0" %}}
Then, use it as any other `message.Subscriber`.