Skip to content

Instantly share code, notes, and snippets.

@yukimochi
Created December 22, 2018 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yukimochi/7330da3972fe0e444a922ada71ca4f34 to your computer and use it in GitHub Desktop.
Save yukimochi/7330da3972fe0e444a922ada71ca4f34 to your computer and use it in GitHub Desktop.
Sidekiq relay to YUKIMOCHI Relay
package main
import (
"fmt"
"os"
"strings"
"github.com/go-redis/redis"
)
func main() {
redis_1 := redis.NewClient(&redis.Options{
Addr: os.Getenv("OLD_REDIS"),
})
redis_2 := redis.NewClient(&redis.Options{
Addr: os.Getenv("NEW_REDIS"),
})
nSub := 0
fmt.Println("-- subscriptions --")
domainKeys, _ := redis_1.Keys("subscription:*").Result()
for _, domainKey := range domainKeys {
domain := strings.Replace(domainKey, "subscription:", "", 1)
inbox, _ := redis_1.HGet(domainKey, "inbox_url").Result()
fmt.Println(domain, inbox)
redis_2.HSet("relay:subscription:"+domain, "inbox_url", inbox)
nSub++
}
fmt.Println("Result : ", nSub)
nLim := 0
fmt.Println("-- limited --")
domainKeys, _ = redis_1.Keys("limited_domain:*").Result()
for _, domainKey := range domainKeys {
domain := strings.Replace(domainKey, "limited_domain:", "", 1)
fmt.Println(domain)
redis_2.HSet("relay:config:limitedDomain", domain, "1").Result()
nLim++
}
fmt.Println("Result : ", nLim)
nBlo := 0
fmt.Println("-- blocked --")
domainKeys, _ = redis_1.Keys("blocked_domain:*").Result()
for _, domainKey := range domainKeys {
domain := strings.Replace(domainKey, "blocked_domain:", "", 1)
fmt.Println(domain)
redis_2.HSet("relay:config:blockedDomain", domain, "1").Result()
nBlo++
}
fmt.Println("Result : ", nBlo)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment