Skip to content

Redis

The same handlers run over Redis pub/sub or Kafka; only the server and client change:

app.ConnectMicroservice(redis.NewServer(redis.Options{Addr: "localhost:6379"}))
redis.ClientModule(redis.ClientOptions{Redis: goredis.Options{Addr: "localhost:6379"}}) // provides *micro.Client
app.ConnectMicroservice(kafka.NewServer(kafka.Options{Brokers: []string{"localhost:9092"}, GroupID: "users"}))
kafka.ClientModule(kafka.ClientOptions{Brokers: []string{"localhost:9092"}})

Redis patterns with *, ? or [ are glob subscriptions (orders.*). Redis pub/sub keeps nothing: an event with no server running is lost, and a request with no server fails at once with micro.ErrNoHandler. Kafka patterns starting with ^ are regexps over topic names (^orders\..*); every server in one GroupID shares the partitions, and each client gets its own reply topic, deleted when it closes.