Example #1
0
func toRedis(indexName string, logType string, msg string) {
	var message web_socket.RedisMessage
	log.Println("Sending message to redis")
	message = web_socket.RedisMessage{ApiKey: indexName, Data: map[string]string{
		"type":     "log_message",
		"log_type": logType,
		"message":  msg,
	}}
	message.Send(redisConn)
}
Example #2
0
func initTimers() {
	ticker := time.NewTicker(1 * time.Second)

	defer ticker.Stop()

	for range ticker.C {
		prs.Lock()

		var message web_socket.RedisMessage
		for apiKey, logsPerSecond := range prs.Logs {
			if logsPerSecond > 0 {
				message = web_socket.RedisMessage{ApiKey: apiKey, Data: map[string]interface{}{
					"type":  "logs_per_second",
					"count": logsPerSecond,
				}}

				message.Send(redisConn)
			}
		}

		prs.Logs = make(map[string]int)
		prs.Unlock()
	}
}