Skip to content

Commit 9de0b03

Browse files
authored
refactor(main): align backend codebase (#1048)
Because - we'd like to extract common components to share across all backends using the `x` package This commit - upgrades to Go 1.24.2 - adopts `x/log` - replaces the `external` package with `x/client` - removes tedious OTEL span and log codes (a more elegant middleware approach will be adopted) - improves naming consistency
1 parent 893cf5b commit 9de0b03

File tree

36 files changed

+735
-1697
lines changed

36 files changed

+735
-1697
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG GOLANG_VERSION=1.24.2
1+
ARG GOLANG_VERSION=1.24.4
22
FROM golang:${GOLANG_VERSION}-bullseye AS build
33

44
ARG TARGETOS TARGETARCH
@@ -51,7 +51,7 @@ RUN --mount=type=bind,target=. \
5151
RUN --mount=type=bind,target=. \
5252
--mount=type=cache,target=/go/pkg/mod \
5353
--mount=type=cache,target=/root/.cache/go-build \
54-
GOOS=$TARGETOS GOARCH=$TARGETARCH \
54+
GOOS=$TARGETOS GOARCH=$TARGETARCH \
5555
go build -ldflags "-w -X main.serviceVersion=${SERVICE_VERSION} -X main.serviceName=${SERVICE_NAME}-worker" \
5656
-tags=ocr,onnx -o /${SERVICE_NAME}-worker ./cmd/worker
5757

Dockerfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG GOLANG_VERSION=1.24.2
1+
ARG GOLANG_VERSION=1.24.4
22
FROM golang:${GOLANG_VERSION}-bullseye
33

44
ARG SERVICE_NAME

cmd/init/definitionupdater/updater.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ import (
99
"github.com/launchdarkly/go-semver"
1010

1111
"github.com/instill-ai/pipeline-backend/pkg/datamodel"
12-
"github.com/instill-ai/pipeline-backend/pkg/logger"
1312
"github.com/instill-ai/pipeline-backend/pkg/repository"
1413

1514
componentstore "github.com/instill-ai/pipeline-backend/pkg/component/store"
1615
errdomain "github.com/instill-ai/pipeline-backend/pkg/errors"
1716
pb "github.com/instill-ai/protogen-go/pipeline/pipeline/v1beta"
17+
logx "github.com/instill-ai/x/log"
1818
)
1919

2020
// UpdateComponentDefinitionIndex updates the component definitions in the
2121
// database based on latest version of their definition.json file.
2222
func UpdateComponentDefinitionIndex(ctx context.Context, repo repository.Repository) error {
23-
logger, _ := logger.GetZapLogger(ctx)
23+
logger, _ := logx.GetZapLogger(ctx)
2424

2525
defs := componentstore.Init(componentstore.InitParams{
2626
Logger: logger,

cmd/init/main.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"log"
66

77
"github.com/redis/go-redis/v9"
8-
"go.opentelemetry.io/otel"
98

109
"github.com/instill-ai/pipeline-backend/cmd/init/definitionupdater"
1110

@@ -16,14 +15,12 @@ import (
1615
)
1716

1817
func main() {
18+
1919
if err := config.Init(config.ParseConfigFlag()); err != nil {
2020
log.Fatal(err.Error())
2121
}
22+
2223
ctx, cancel := context.WithCancel(context.Background())
23-
ctx, span := otel.Tracer("init-tracer").Start(ctx,
24-
"main",
25-
)
26-
defer span.End()
2724
defer cancel()
2825

2926
db := database.GetConnection()

0 commit comments

Comments
 (0)