Skip to content

Commit fb642aa

Browse files
author
Alvin Reyes
authored
feat: move the db objects to the delta main (#152)
2 parents 7094c36 + f47e5c9 commit fb642aa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1272
-139
lines changed

api/admin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"encoding/hex"
88
"encoding/json"
99
"fmt"
10-
model "github.com/application-research/delta-db/db_models"
10+
model "delta/models"
1111
"github.com/filecoin-project/go-address"
1212
"github.com/filecoin-project/lotus/chain/types"
1313
"github.com/google/uuid"

api/deal.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"delta/utils"
1010
"encoding/json"
1111
"fmt"
12-
model "github.com/application-research/delta-db/db_models"
12+
model "delta/models"
1313
"github.com/google/uuid"
1414
"github.com/ipfs/go-cid"
1515
"github.com/multiformats/go-multiaddr"

api/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package api
33
import (
44
"context"
55
"delta/core"
6-
"github.com/application-research/delta-db/db_models"
6+
"delta/models"
77
"github.com/labstack/echo/v4"
88
"go.opentelemetry.io/otel"
99
"go.opentelemetry.io/otel/attribute"

api/open_info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package api
33
import (
44
"context"
55
"delta/core"
6-
model "github.com/application-research/delta-db/db_models"
6+
model "delta/models"
77
"github.com/filecoin-project/go-address"
88
"github.com/filecoin-project/lotus/chain/types"
99
"github.com/labstack/echo/v4"

api/open_stats.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"delta/core"
55
"delta/jobs"
66
"delta/utils"
7-
model "github.com/application-research/delta-db/db_models"
7+
model "delta/models"
88
"github.com/labstack/echo/v4"
99
"strconv"
1010
)

api/repair_retry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"delta/jobs"
66
"delta/utils"
77
"encoding/json"
8-
model "github.com/application-research/delta-db/db_models"
8+
model "delta/models"
99
"github.com/labstack/echo/v4"
1010
"strings"
1111
"time"

api/router.go

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,15 @@ package api
33
import (
44
"delta/config"
55
"delta/core"
6-
"delta/utils"
6+
_ "delta/docs/swagger"
77
"encoding/json"
88
"fmt"
99
"net/http"
1010
"os"
1111
"os/signal"
1212
"strings"
1313
"syscall"
14-
"time"
1514

16-
_ "delta/docs/swagger"
17-
"github.com/application-research/delta-db/messaging"
1815
logging "github.com/ipfs/go-log/v2"
1916
"github.com/labstack/echo/v4"
2017
"github.com/labstack/echo/v4/middleware"
@@ -268,46 +265,6 @@ func ValidateRequestBody() echo.MiddlewareFunc {
268265
// ErrorHandler It's a function that is called when an error occurs.
269266
func ErrorHandler(err error, c echo.Context) {
270267

271-
ip := DeltaNodeConfig.Node.AnnounceAddrIP
272-
273-
// get the request body and log it
274-
275-
s := struct {
276-
RemoteIP string `json:"remote_ip"`
277-
PublicIP string `json:"public_ip"`
278-
Host string `json:"host"`
279-
Referer string `json:"referer"`
280-
Request string `json:"request"`
281-
Path string `json:"path"`
282-
ErrorDetails string `json:"details"`
283-
}{
284-
RemoteIP: c.RealIP(),
285-
PublicIP: ip,
286-
Host: c.Request().Host,
287-
Referer: c.Request().Referer(),
288-
Request: c.Request().RequestURI,
289-
Path: c.Path(),
290-
ErrorDetails: err.Error(),
291-
}
292-
293-
b, errM := json.Marshal(s)
294-
if errM != nil {
295-
log.Error(errM)
296-
}
297-
298-
// It's sending the error to the log server.
299-
utils.GlobalDeltaDataReporter.TraceLog(
300-
messaging.LogEvent{
301-
LogEventType: "Error: " + core.GetHostname() + " " + c.Request().Method + " " + c.Path(),
302-
SourceHost: core.GetHostname(),
303-
SourceIP: ip,
304-
LogEventObject: b,
305-
LogEvent: c.Path(),
306-
DeltaUuid: DeltaNodeConfig.Node.InstanceUuid,
307-
CreatedAt: time.Now(),
308-
UpdatedAt: time.Now(),
309-
})
310-
311268
var httpRespErr *HttpError
312269
if xerrors.As(err, &httpRespErr) {
313270
log.Errorf("handler error: %s", err)

api/stats.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package api
22

33
import (
44
"delta/core"
5-
model "github.com/application-research/delta-db/db_models"
5+
model "delta/models"
66
"strings"
77

88
"github.com/labstack/echo/v4"

api/websocket.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package api
33
import (
44
"delta/core"
55
"fmt"
6-
model "github.com/application-research/delta-db/db_models"
6+
model "delta/models"
77
"github.com/gorilla/websocket"
88
"github.com/labstack/echo/v4"
99
"sync"

cmd/daemon.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@ import (
44
"delta/api"
55
c "delta/config"
66
"delta/core"
7+
_ "delta/models"
78
"delta/utils"
89
"fmt"
9-
"github.com/application-research/delta-db/db_models"
10-
_ "github.com/application-research/delta-db/db_models"
11-
"github.com/application-research/delta-db/messaging"
1210
"github.com/filecoin-project/go-address"
1311
"github.com/jasonlvhit/gocron"
1412
"github.com/urfave/cli/v2"
1513
"runtime"
16-
"time"
1714
)
1815

1916
// DaemonCmd Creating a new command called `daemon` that will run the API node.
@@ -186,17 +183,6 @@ By: Protocol Labs - Outercore Engineering
186183
` + utils.Reset + utils.Red + "version: " + cfg.Common.Version + utils.Reset)
187184

188185
fmt.Println(utils.Blue + "Reporting Delta startup logs" + utils.Reset)
189-
utils.GlobalDeltaDataReporter.Trace(messaging.DeltaMetricsBaseMessage{
190-
ObjectType: "DeltaStartupLogs",
191-
Object: db_models.DeltaStartupLogs{
192-
NodeInfo: core.GetHostname(),
193-
OSDetails: runtime.GOARCH + " " + runtime.GOOS,
194-
IPAddress: ip,
195-
DeltaNodeUuid: cfg.Node.InstanceUuid,
196-
CreatedAt: time.Now(),
197-
UpdatedAt: time.Now(),
198-
},
199-
})
200186
fmt.Println(utils.Blue + "Reporting Delta startup logs... DONE" + utils.Reset)
201187
fmt.Println("----------------------------------")
202188
fmt.Println(utils.Green + "Welcome! Delta daemon is running..." + utils.Reset)

0 commit comments

Comments
 (0)