Skip to content

Commit

Permalink
removes grpc and makes the seawatcher great again
Browse files Browse the repository at this point in the history
  • Loading branch information
benleb committed Oct 7, 2023
1 parent 8004b37 commit ea7a0aa
Show file tree
Hide file tree
Showing 25 changed files with 774 additions and 3,703 deletions.
26 changes: 9 additions & 17 deletions cmd/live.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import (
"github.com/benleb/gloomberg/internal/gbl"
"github.com/benleb/gloomberg/internal/jobs"
"github.com/benleb/gloomberg/internal/nemo/gloomberg"
"github.com/benleb/gloomberg/internal/nemo/gloomberg/gbgrpc"
"github.com/benleb/gloomberg/internal/nemo/gloomberg/remote"
"github.com/benleb/gloomberg/internal/nemo/provider"
"github.com/benleb/gloomberg/internal/nemo/token"
"github.com/benleb/gloomberg/internal/nemo/totra"
Expand Down Expand Up @@ -95,12 +93,10 @@ func runGloomberg(_ *cobra.Command, _ []string) {

gloomberg.PrModf("exp", "active experiments πŸ§ͺ %s", style.BoldAlmostWhite(strings.Join(activeExperiments.ToSlice(), style.GrayStyle.Render(" Β· "))))

go func() {
gb.DegenDB = degendb.NewDegenDB()
}()

// cleanup for redis db/cache
// defer gb.Rdb.Close()
// disabled for now
// go func() {
// gb.DegenDB = degendb.NewDegenDB()
// }()

// compatibility with old config key
var providerConfig interface{}
Expand Down Expand Up @@ -374,14 +370,10 @@ func runGloomberg(_ *cobra.Command, _ []string) {

//
// subscribe to OpenSea API
if viper.GetBool("seawatcher.local") || viper.GetBool("grpc.client.enabled") || viper.GetBool("pubsub.client.enabled") {
if viper.GetBool("seawatcher.local") || viper.GetBool("pubsub.client.enabled") {
go trapri.SeaWatcherEventsHandler(gb)
}

if viper.GetBool("grpc.server.enabled") {
gbgrpc.StartServer(gb, seawa)
}

//
// subscribe to redis pubsub channel to receive events from gloomberg central
if viper.GetBool("pubsub.client.enabled") {
Expand All @@ -391,12 +383,12 @@ func runGloomberg(_ *cobra.Command, _ []string) {
go pusu.SubscribeToListingsViaRedis(gb)

// initially send all our slugs & events to subscribe to
go gb.SendSlugsToServer()
go gb.PublishOwnCollectionsSlugs()

// subscribe to redis pubsub mgmt channel to listen for "SendSlugs" events
go func() {
err := gb.Rdb.Receive(context.Background(), gb.Rdb.B().Subscribe().Channel(internal.PubSubSeaWatcherMgmt).Build(), func(msg rueidis.PubSubMessage) {
gbl.Log.Debug(fmt.Sprintf("πŸš‡ received msg on %s: %s", msg.Channel, msg.Message))
gbl.Log.Debug(fmt.Sprintf("πŸ‘” received msg on %s: %s", msg.Channel, msg.Message))

var mgmtEvent *seawaModels.MgmtEvent

Expand All @@ -405,8 +397,8 @@ func runGloomberg(_ *cobra.Command, _ []string) {
}

if mgmtEvent.Action == seawaModels.SendSlugs {
gbl.Log.Info(fmt.Sprintf("πŸš‡ SendSlugs received on channel %s", msg.Channel))
gb.SendSlugsToServer()
gbl.Log.Info(fmt.Sprintf("πŸ‘” SendSlugs received on channel %s", msg.Channel))
gb.PublishOwnCollectionsSlugs()
}
})
if err != nil {
Expand Down
14 changes: 0 additions & 14 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"fmt"
"net"
"os"
"strings"
"time"
Expand All @@ -26,10 +25,6 @@ var (
certPath string
keyPath string

// grpc.
grpcServerListen net.IP
grpcClientHost net.IP

gb *gloomberg.Gloomberg
)

Expand Down Expand Up @@ -138,15 +133,6 @@ func init() {
viper.SetDefault("cache.salira_ttl", 1*time.Hour)
viper.SetDefault("cache.slug_ttl", 3*24*time.Hour)
viper.SetDefault("cache.notifications_lock_ttl", time.Millisecond*1337)

// grpc server
viper.SetDefault("grpc.server.enabled", false)
viper.SetDefault("grpc.server.listenAddress", net.IPv4(127, 0, 0, 1))
viper.SetDefault("grpc.server.port", 31337)
// grpc client
viper.SetDefault("grpc.client.enabled", false)
viper.SetDefault("grpc.client.host", net.IPv4(127, 0, 0, 1))
viper.SetDefault("grpc.client.port", 31337)
}

// initConfig reads in config file and ENV variables if set.
Expand Down
16 changes: 0 additions & 16 deletions cmd/seawatcherCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"net"

"github.com/benleb/gloomberg/internal/nemo/gloomberg/gbgrpc"
"github.com/benleb/gloomberg/internal/seawa"
"github.com/benleb/gloomberg/internal/trapri"
"github.com/benleb/gloomberg/internal/web"
Expand All @@ -28,16 +27,6 @@ func init() {
viper.SetDefault("manifoldSNS.enabled", false)
viper.SetDefault("manifoldSNS.host", net.IPv4(127, 0, 0, 1))
viper.SetDefault("manifoldSNS.port", viper.GetUint16("web.port")-1)

// grpc
seaWatcherCmd.Flags().Uint16("grpc-port", 31337, "gRPC server port")
_ = viper.BindPFlag("grpc.port", seaWatcherCmd.Flags().Lookup("grpc-port"))
// grpc server
seaWatcherCmd.Flags().IPVar(&grpcServerListen, "grpc-listen", nil, "gRPC server listen address")
_ = viper.BindPFlag("grpc.listen", seaWatcherCmd.Flags().Lookup("grpc-listen"))
// grpc client
seaWatcherCmd.Flags().IPVar(&grpcClientHost, "grpc", nil, "server gRPC client connects to")
_ = viper.BindPFlag("grpc.client.host", seaWatcherCmd.Flags().Lookup("grpc"))
}

func runSeawatcher(_ *cobra.Command, _ []string) {
Expand Down Expand Up @@ -68,11 +57,6 @@ func runSeawatcher(_ *cobra.Command, _ []string) {
sw.Pr("requested slugs from clients…")
}

// sw.Prf("seaWatcherCmd.CalledAs(): %+v", cmd.CalledAs())
if viper.GetBool("grpc.server.enabled") {
gbgrpc.StartServer(gb, sw)
}

//
// manifold SNS receiver
if viper.GetBool("manifoldSNS.enabled") {
Expand Down
10 changes: 4 additions & 6 deletions internal/degendb/event_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var (
Unknown = &GBEventType{name: "Unknown", actionName: "did something", icon: "❓", openseaEventName: ""}
Transfer = &GBEventType{name: "Transfer", actionName: "transferred", icon: "πŸ“¦", openseaEventName: "item_transferred"}
Sale = &GBEventType{name: "Sale", actionName: "sold", icon: "πŸ’°", openseaEventName: "item_sold"}
Purchase = &GBEventType{name: "Purchase", actionName: "purchased", icon: "πŸ’°", openseaEventName: "item_sold"}
Purchase = &GBEventType{name: "Purchase", actionName: "purchased", icon: "πŸ›οΈ", openseaEventName: "item_sold"}
Mint = &GBEventType{name: "Mint", actionName: "minted", icon: "Ⓜ️", openseaEventName: ""}
Airdrop = &GBEventType{name: "Airdrop", actionName: "got airdropped", icon: "🎁", openseaEventName: ""}
Burn = &GBEventType{name: "Burn", actionName: "burned", icon: "πŸ”₯", openseaEventName: ""}
Expand All @@ -57,11 +57,10 @@ var (
Listing = &GBEventType{name: "Listing", actionName: "listed", icon: "πŸ“’", openseaEventName: "item_listed"}
Bid = &GBEventType{name: "Bid", actionName: "(got) bid", icon: "πŸ’¦", openseaEventName: "item_received_bid"}
OwnBid = &GBEventType{name: "OwnBid", actionName: "bid", icon: "πŸ€‘", openseaEventName: ""}
Offer = &GBEventType{name: "Offer", actionName: "(got) offered", icon: "πŸ’¦", openseaEventName: "item_received_offer"}
AcceptedOffer = &GBEventType{name: "AcceptedOffer", actionName: "accepted offer", icon: "🀝", openseaEventName: ""}
CollectionOffer = &GBEventType{name: "CollectionOffer", actionName: "(got) collection-offered", icon: "🧊", openseaEventName: "collection_offer"}
CollectionOffer = &GBEventType{name: "CollectionOffer", actionName: "(got) collection-offered", icon: "β˜‚οΈ", openseaEventName: "collection_offer"} // 🧊
AcceptedCollectionOffer = &GBEventType{name: "AcceptedCollectionOffer", actionName: "accepted collection offer", icon: "🀝", openseaEventName: ""}
MetadataUpdate = &GBEventType{name: "MetadataUpdate", actionName: "metadata updated", icon: "♻️", openseaEventName: "item_metadata_updated"}
MetadataUpdated = &GBEventType{name: "MetadataUpdated", actionName: "metadata updated", icon: "♻️", openseaEventName: "item_metadata_updated"}
Cancelled = &GBEventType{name: "Cancelled", actionName: "cancelled", icon: "❌", openseaEventName: "item_cancelled"}

// event type sets.
Expand All @@ -73,8 +72,7 @@ var (
"item_sold": Sale,
"item_listed": Listing,
"item_received_bid": Bid,
"item_received_offer": Offer,
"item_metadata_updated": MetadataUpdate,
"item_metadata_updated": MetadataUpdated,
"item_cancelled": Cancelled,
"collection_offer": CollectionOffer,
}
Expand Down
212 changes: 0 additions & 212 deletions internal/nemo/gloomberg/gbgrpc/client.go

This file was deleted.

0 comments on commit ea7a0aa

Please sign in to comment.