Created
December 22, 2018 15:11
-
-
Save yukimochi/7330da3972fe0e444a922ada71ca4f34 to your computer and use it in GitHub Desktop.
Sidekiq relay to YUKIMOCHI Relay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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