|
1 | 1 | package ingest
|
2 | 2 |
|
3 | 3 | import (
|
4 |
| - "context" |
5 |
| - |
6 | 4 | "github.com/frain-dev/convoy/config"
|
7 | 5 | "github.com/frain-dev/convoy/database/postgres"
|
8 | 6 | "github.com/frain-dev/convoy/internal/pkg/cli"
|
| 7 | + "github.com/frain-dev/convoy/internal/pkg/memorystore" |
9 | 8 | "github.com/frain-dev/convoy/internal/pkg/pubsub"
|
10 | 9 | "github.com/frain-dev/convoy/internal/pkg/server"
|
11 | 10 | "github.com/frain-dev/convoy/pkg/log"
|
@@ -56,13 +55,24 @@ func AddIngestCommand(a *cli.App) *cobra.Command {
|
56 | 55 |
|
57 | 56 | lo.SetLevel(lvl)
|
58 | 57 |
|
59 |
| - sourcePool := pubsub.NewSourcePool(lo) |
60 |
| - sourceLoader := pubsub.NewSourceLoader(endpointRepo, sourceRepo, projectRepo, a.Queue, sourcePool, lo) |
| 58 | + sourceLoader := pubsub.NewSourceLoader(endpointRepo, sourceRepo, projectRepo, lo) |
| 59 | + sourceTable := memorystore.NewTable(memorystore.OptionSyncer(sourceLoader)) |
| 60 | + |
| 61 | + err = memorystore.DefaultStore.Register("sources", sourceTable) |
| 62 | + if err != nil { |
| 63 | + return err |
| 64 | + } |
| 65 | + |
| 66 | + go memorystore.DefaultStore.Sync(cmd.Context(), interval) |
| 67 | + |
| 68 | + ingest, err := pubsub.NewIngest(cmd.Context(), sourceTable, a.Queue, lo) |
| 69 | + if err != nil { |
| 70 | + return err |
| 71 | + } |
61 | 72 |
|
62 |
| - stop := make(chan struct{}) |
63 |
| - go sourceLoader.Run(context.Background(), interval, stop) |
| 73 | + go ingest.Run() |
64 | 74 |
|
65 |
| - srv := server.NewServer(cfg.Server.HTTP.IngestPort, func() { stop <- struct{}{} }) |
| 75 | + srv := server.NewServer(cfg.Server.HTTP.IngestPort, func() {}) |
66 | 76 | srv.SetHandler(chi.NewMux())
|
67 | 77 |
|
68 | 78 | srv.Listen()
|
|
0 commit comments