rocksdb #29
2 changed files with 35 additions and 0 deletions
|
@ -41,6 +41,8 @@ type Args struct {
|
|||
DisableRocksDBRefresh bool
|
||||
DisableResolve bool
|
||||
DisableBlockingAndFiltering bool
|
||||
BlockingChannelIds []string
|
||||
FilteringChannelIds []string
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -65,6 +67,11 @@ const (
|
|||
DefaultDisableBlockingAndFiltering = false
|
||||
)
|
||||
|
||||
var (
|
||||
DefaultBlockingChannelIds = []string{}
|
||||
DefaultFilteringChannelIds = []string{}
|
||||
)
|
||||
|
||||
// GetEnvironment takes the environment variables as an array of strings
|
||||
// and a getkeyval function to turn it into a map.
|
||||
func GetEnvironment(data []string, getkeyval func(item string) (key, val string)) map[string]string {
|
||||
|
@ -109,6 +116,8 @@ func ParseArgs(searchRequest *pb.SearchRequest) *Args {
|
|||
cacheTTL := parser.Int("", "cachettl", &argparse.Options{Required: false, Help: "Cache TTL in minutes", Default: DefaultCacheTTL})
|
||||
peerFile := parser.String("", "peerfile", &argparse.Options{Required: false, Help: "Initial peer file for federation", Default: DefaultPeerFile})
|
||||
country := parser.String("", "country", &argparse.Options{Required: false, Help: "Country this node is running in. Default US.", Default: DefaultCountry})
|
||||
blockingChannelIds := parser.StringList("", "blocking-channel-ids", &argparse.Options{Required: false, Help: "Blocking channel ids", Default: DefaultBlockingChannelIds})
|
||||
filteringChannelIds := parser.StringList("", "filtering-channel-ids", &argparse.Options{Required: false, Help: "Filtering channel ids", Default: DefaultFilteringChannelIds})
|
||||
|
||||
debug := parser.Flag("", "debug", &argparse.Options{Required: false, Help: "enable debug logging", Default: false})
|
||||
disableEs := parser.Flag("", "disable-es", &argparse.Options{Required: false, Help: "Disable elastic search, for running/testing independently", Default: false})
|
||||
|
@ -160,6 +169,8 @@ func ParseArgs(searchRequest *pb.SearchRequest) *Args {
|
|||
DisableRocksDBRefresh: *disableRocksDBRefresh,
|
||||
DisableResolve: *disableResolve,
|
||||
DisableBlockingAndFiltering: *disableBlockingAndFiltering,
|
||||
BlockingChannelIds: *blockingChannelIds,
|
||||
FilteringChannelIds: *filteringChannelIds,
|
||||
}
|
||||
|
||||
if esHost, ok := environment["ELASTIC_HOST"]; ok {
|
||||
|
|
|
@ -3,6 +3,7 @@ package server
|
|||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"hash"
|
||||
"log"
|
||||
|
@ -21,6 +22,7 @@ import (
|
|||
"github.com/olivere/elastic/v7"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
logrus "github.com/sirupsen/logrus"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/reflection"
|
||||
)
|
||||
|
@ -196,6 +198,28 @@ func MakeHubServer(ctx context.Context, args *Args) *Server {
|
|||
// Can't load the db, fail loudly
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
blockingChannelHashes := make([][]byte, 0, 10)
|
||||
filteringChannelHashes := make([][]byte, 0, 10)
|
||||
|
||||
for _, id := range args.BlockingChannelIds {
|
||||
hash, err := hex.DecodeString(id)
|
||||
if err != nil {
|
||||
logrus.Warn("Invalid channel id: ", id)
|
||||
}
|
||||
blockingChannelHashes = append(blockingChannelHashes, hash)
|
||||
}
|
||||
|
||||
for _, id := range args.FilteringChannelIds {
|
||||
hash, err := hex.DecodeString(id)
|
||||
if err != nil {
|
||||
logrus.Warn("Invalid channel id: ", id)
|
||||
}
|
||||
filteringChannelHashes = append(filteringChannelHashes, hash)
|
||||
}
|
||||
|
||||
myDB.BlockingChannelHashes = blockingChannelHashes
|
||||
myDB.FilteringChannelHashes = filteringChannelHashes
|
||||
}
|
||||
|
||||
s := &Server{
|
||||
|
|
Loading…
Reference in a new issue