Mode:
Duration:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main
import "fmt"
type Subscriber struct {
Name string
Type string
}
func publishMessage(topic string, message string, subscribers []Subscriber) {
fmt.Println("SNS Topic:", topic)
fmt.Println("Message:", message)
for _, subscriber := range subscribers {
fmt.Println("Delivered to:", subscriber.Name, "(", subscriber.Type, ")")
}
}
func main() {
subscribers := []Subscriber{
{Name: "Email Service", Type: "Email"},
{Name: "SMS Service", Type: "SMS"},
{Name: "Order Service", Type: "HTTP"},
}
publishMessage(
"order-events",
"New order created",
subscribers,
)
}Coding works best on desktop or with an external keyboard.