MCPcopy Create free account
hub / github.com/ebosas/microservices / main

Function main

cmd/cache/cache.go:18–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16var ctx = context.Background()
17
18func main() {
19 fmt.Println("[Cache service]")
20
21 // Redis connection
22 connR := redis.NewClient(&redis.Options{
23 Addr: conf.RedisURL,
24 Password: "", // no password set
25 DB: 0, // use default DB
26 })
27
28 // RabbitMQ connection
29 connMQ, err := rabbit.GetConn(conf.RabbitURL)
30 if err != nil {
31 log.Fatalf("rabbit connection: %s", err)
32 }
33 defer connMQ.Close()
34
35 err = connMQ.DeclareTopicExchange(conf.Exchange)
36 if err != nil {
37 log.Fatalf("declare exchange: %s", err)
38 }
39
40 // Start a Rabbit consumer with a message processing handler.
41 connMQ.StartConsumer(conf.Exchange, conf.QueueCache, conf.KeyCache, func(d amqp.Delivery) bool {
42 return updateRedis(d, connR)
43 })
44
45 select {}
46}
47
48// updateRedis updates Redis with a new Rabbit message.
49func updateRedis(d amqp.Delivery, c *redis.Client) bool {

Callers

nothing calls this directly

Calls 5

GetConnFunction · 0.92
updateRedisFunction · 0.85
CloseMethod · 0.80
DeclareTopicExchangeMethod · 0.80
StartConsumerMethod · 0.80

Tested by

no test coverage detected