Skip to content

Commit bd9c19f

Browse files
authored
Djt/1012/refactor (#103)
* Refactoring to remove pgqueue and pgmanager * Other updates for refactoring
1 parent f662025 commit bd9c19f

Some content is hidden

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

105 files changed

+214
-12401
lines changed

Makefile

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
# Executables
22
GO ?= $(shell which go 2>/dev/null)
33
DOCKER ?= $(shell which docker 2>/dev/null)
4-
NPM ?= $(shell which npm 2>/dev/null)
54

65
# Locations
76
BUILD_DIR ?= build
87
CMD_DIR := $(wildcard cmd/*)
98
PLUGIN_DIR := $(wildcard plugin/*)
10-
NPM_DIR := $(wildcard npm/*)
119

1210
# VERBOSE=1
1311
ifneq ($(VERBOSE),)
@@ -44,9 +42,9 @@ all: clean build
4442
###############################################################################
4543
# BUILD
4644

47-
# Compile NPM and build the commands in the cmd directory
45+
# Compile and build the commands in the cmd directory
4846
.PHONY: build
49-
build: $(NPM_DIR) build-docker
47+
build: build-docker
5048

5149
# Build the commands in the cmd directory
5250
.PHONY: build-docker
@@ -59,21 +57,16 @@ $(CMD_DIR): go-dep mkdir
5957

6058
# Build the plugins
6159
.PHONY: plugins
62-
plugins: $(NPM_DIR) $(PLUGIN_DIR)
60+
plugins: $(PLUGIN_DIR)
6361

6462
# Build the plugins
6563
$(PLUGIN_DIR): go-dep mkdir
6664
@echo Build plugin $(notdir $@) GOOS=${OS} GOARCH=${ARCH}
6765
@GOOS=${OS} GOARCH=${ARCH} ${GO} build -buildmode=plugin ${BUILD_FLAGS} -o ${BUILD_DIR}/$(notdir $@).plugin ./$@
6866

69-
# Build the NPM packages
70-
$(NPM_DIR): npm-dep
71-
@echo Build npm $(notdir $@)
72-
@cd $@ && npm install && npm run dist
73-
7467
# Build the docker image
7568
.PHONY: docker
76-
docker: docker-dep ${NPM_DIR}
69+
docker: docker-dep
7770
@echo build docker image ${DOCKER_TAG} OS=${OS} ARCH=${ARCH} SOURCE=${DOCKER_SOURCE} VERSION=${VERSION}
7871
@${DOCKER} build \
7972
--tag ${DOCKER_TAG} \
@@ -126,11 +119,7 @@ mkdir:
126119
clean:
127120
@echo Clean $(BUILD_DIR)
128121
@rm -fr $(BUILD_DIR)
129-
@${GO} clean
130-
@for dir in $(NPM_DIR); do \
131-
echo "Cleaning npm $$dir"; \
132-
cd $$dir && ${NPM} run clean; \
133-
done
122+
@${GO} clean -modcache
134123

135124
###############################################################################
136125
# DEPENDENCIES
@@ -142,7 +131,3 @@ go-dep:
142131
.PHONY: docker-dep
143132
docker-dep:
144133
@test -f "${DOCKER}" && test -x "${DOCKER}" || (echo "Missing docker binary" && exit 1)
145-
146-
.PHONY: npm-dep
147-
npm-dep:
148-
@test -f "${NPM}" && test -x "${NPM}" || (echo "Missing npm binary" && exit 1)

cmd/server/main.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import (
99
certmanager "github.com/mutablelogic/go-server/pkg/cert/cmd"
1010
cmd "github.com/mutablelogic/go-server/pkg/cmd"
1111
ldap "github.com/mutablelogic/go-server/pkg/ldap/cmd"
12-
pgmanager "github.com/mutablelogic/go-server/pkg/pgmanager/cmd"
13-
pgqueue "github.com/mutablelogic/go-server/pkg/pgqueue/cmd"
1412
)
1513

1614
///////////////////////////////////////////////////////////////////////////////
@@ -20,18 +18,6 @@ type CLI struct {
2018
ServiceCommands
2119
Service2Commands
2220

23-
PG struct {
24-
pgmanager.DatabaseCommands
25-
pgmanager.SchemaCommands
26-
pgmanager.ObjectCommands
27-
pgmanager.RoleCommands
28-
pgmanager.ConnectionCommands
29-
pgmanager.TablespaceCommands
30-
pgqueue.QueueCommands
31-
pgqueue.TaskCommands
32-
pgqueue.TickerCommands
33-
} `cmd:""`
34-
3521
Cert struct {
3622
certmanager.NameCommands
3723
certmanager.CertCommands

cmd/server/service.go

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,10 @@ import (
1818

1919
// Plugins
2020
auth "github.com/mutablelogic/go-server/pkg/auth/config"
21-
cert "github.com/mutablelogic/go-server/pkg/cert/config"
2221
httprouter "github.com/mutablelogic/go-server/pkg/httprouter/config"
2322
httpserver "github.com/mutablelogic/go-server/pkg/httpserver/config"
2423
ldap "github.com/mutablelogic/go-server/pkg/ldap/config"
2524
logger "github.com/mutablelogic/go-server/pkg/logger/config"
26-
metrics "github.com/mutablelogic/go-server/pkg/metrics/config"
27-
pg "github.com/mutablelogic/go-server/pkg/pgmanager/config"
28-
pgqueue "github.com/mutablelogic/go-server/pkg/pgqueue/config"
2925
)
3026

3127
///////////////////////////////////////////////////////////////////////////////
@@ -109,30 +105,7 @@ func (cmd *ServiceRunCommand) Run(app server.Cmd) error {
109105
// Return success
110106
return nil
111107
}))
112-
err = errors.Join(err, provider.Load("pgpool", "main", func(ctx context.Context, label string, config server.Plugin) error {
113-
pgpool := config.(*pg.Config)
114108

115-
// Set router
116-
if router, ok := provider.Task(ctx, "httprouter.main").(server.HTTPRouter); !ok || router == nil {
117-
return httpresponse.ErrInternalError.With("Invalid router")
118-
} else {
119-
pgpool.Router = router
120-
}
121-
122-
// Set trace
123-
if app.GetDebug() == server.Trace {
124-
pgpool.Trace = func(ctx context.Context, query string, args any, err error) {
125-
if err != nil {
126-
ref.Log(ctx).With("args", args).Print(ctx, err, " ON ", query)
127-
} else {
128-
ref.Log(ctx).With("args", args).Debug(ctx, query)
129-
}
130-
}
131-
}
132-
133-
// Return success
134-
return nil
135-
}))
136109
err = errors.Join(err, provider.Load("auth", "main", func(ctx context.Context, label string, config server.Plugin) error {
137110
auth := config.(*auth.Config)
138111

@@ -153,51 +126,6 @@ func (cmd *ServiceRunCommand) Run(app server.Cmd) error {
153126
// Return success
154127
return nil
155128
}))
156-
err = errors.Join(err, provider.Load("pgqueue", "main", func(ctx context.Context, label string, config server.Plugin) error {
157-
pgqueue := config.(*pgqueue.Config)
158-
159-
// Set the router
160-
if router, ok := ref.Provider(ctx).Task(ctx, "httprouter.main").(server.HTTPRouter); !ok || router == nil {
161-
return httpresponse.ErrInternalError.With("Invalid router")
162-
} else {
163-
pgqueue.Router = router
164-
}
165-
166-
// Set the connection pool
167-
if pool, ok := ref.Provider(ctx).Task(ctx, "pgpool.main").(server.PG); !ok || pool == nil {
168-
return httpresponse.ErrInternalError.With("Invalid connection pool")
169-
} else {
170-
pgqueue.Pool = pool
171-
}
172-
173-
return nil
174-
}))
175-
err = errors.Join(err, provider.Load("certmanager", "main", func(ctx context.Context, label string, config server.Plugin) error {
176-
certmanager := config.(*cert.Config)
177-
178-
// Set the router
179-
if router, ok := ref.Provider(ctx).Task(ctx, "httprouter.main").(server.HTTPRouter); !ok || router == nil {
180-
return httpresponse.ErrInternalError.With("Invalid router")
181-
} else {
182-
certmanager.Router = router
183-
}
184-
185-
// Set the connection pool
186-
if pool, ok := ref.Provider(ctx).Task(ctx, "pgpool.main").(server.PG); !ok || pool == nil {
187-
return httpresponse.ErrInternalError.With("Invalid connection pool")
188-
} else {
189-
certmanager.Pool = pool
190-
}
191-
192-
// Set the queue
193-
if queue, ok := ref.Provider(ctx).Task(ctx, "pgqueue.main").(server.PGQueue); !ok || queue == nil {
194-
return httpresponse.ErrInternalError.With("Invalid task queue")
195-
} else {
196-
certmanager.Queue = queue
197-
}
198-
199-
return nil
200-
}))
201129

202130
err = errors.Join(err, provider.Load("ldap", "main", func(ctx context.Context, label string, config server.Plugin) error {
203131
ldap := config.(*ldap.Config)
@@ -221,19 +149,6 @@ func (cmd *ServiceRunCommand) Run(app server.Cmd) error {
221149
return nil
222150
}))
223151

224-
err = errors.Join(err, provider.Load("metrics", "main", func(ctx context.Context, label string, config server.Plugin) error {
225-
metrics := config.(*metrics.Config)
226-
227-
// Set the router
228-
if router, ok := ref.Provider(ctx).Task(ctx, "httprouter.main").(server.HTTPRouter); !ok || router == nil {
229-
return httpresponse.ErrInternalError.With("Invalid router")
230-
} else {
231-
metrics.Router = router
232-
}
233-
234-
return nil
235-
}))
236-
237152
if err != nil {
238153
return err
239154
}

etc/docker/Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN \
1414
OS=${OS} ARCH=${ARCH} make build-docker
1515

1616
# Copy binaries to /usr/local/bin
17-
FROM --platform=${OS}/${ARCH} debian:bookworm-slim
17+
FROM --platform=${OS}/${ARCH} debian:trixie-slim
1818
ARG OS
1919
ARG ARCH
2020
ARG SOURCE
@@ -25,7 +25,6 @@ RUN apt update -y && apt install -y ca-certificates
2525
LABEL org.opencontainers.image.source=https://${SOURCE}
2626

2727
# Entrypoint when running the server
28-
ENV PLUGIN_PATH="/usr/local/bin/*.plugin" \
29-
ENDPOINT="http://:80/"
28+
ENV PLUGIN_PATH="/usr/local/bin/*.plugin" ENDPOINT="http://0.0.0.0:80/"
3029
EXPOSE 80 443
3130
ENTRYPOINT [ "/usr/local/bin/server" ]

go.mod

Lines changed: 58 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,90 @@
11
module github.com/mutablelogic/go-server
22

3-
go 1.23.5
3+
go 1.24.0
4+
5+
toolchain go1.24.2
46

57
require (
6-
github.com/alecthomas/kong v1.10.0
7-
github.com/djthorpe/go-marshaler v1.0.0
8-
github.com/djthorpe/go-pg v1.0.6
9-
github.com/go-ldap/ldap/v3 v3.4.11
10-
github.com/golang-jwt/jwt/v5 v5.2.2
11-
github.com/mutablelogic/go-client v1.0.12
12-
github.com/stretchr/testify v1.10.0
8+
github.com/alecthomas/kong v1.13.0
9+
github.com/go-ldap/ldap/v3 v3.4.12
10+
github.com/golang-jwt/jwt/v5 v5.3.0
11+
github.com/mutablelogic/go-client v1.3.2
12+
github.com/mutablelogic/go-pg v1.1.1
13+
github.com/stretchr/testify v1.11.1
1314
github.com/yinyin/go-ldap-schema-parser v0.0.0-20190716182935-542aadd3dcb5
1415
)
1516

1617
require (
17-
dario.cat/mergo v1.0.0 // indirect
18-
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
19-
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect
18+
dario.cat/mergo v1.0.2 // indirect
19+
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
20+
github.com/Azure/go-ntlmssp v0.1.0 // indirect
2021
github.com/Microsoft/go-winio v0.6.2 // indirect
21-
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
22-
github.com/containerd/containerd v1.7.27 // indirect
22+
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
23+
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
24+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
25+
github.com/containerd/errdefs v1.0.0 // indirect
26+
github.com/containerd/errdefs/pkg v0.3.0 // indirect
2327
github.com/containerd/log v0.1.0 // indirect
2428
github.com/containerd/platforms v0.2.1 // indirect
2529
github.com/cpuguy83/dockercfg v0.3.2 // indirect
2630
github.com/davecgh/go-spew v1.1.1 // indirect
2731
github.com/distribution/reference v0.6.0 // indirect
2832
github.com/djthorpe/go-errors v1.0.3 // indirect
29-
github.com/docker/docker v27.1.1+incompatible // indirect
30-
github.com/docker/go-connections v0.5.0 // indirect
33+
github.com/docker/docker v28.5.2+incompatible // indirect
34+
github.com/docker/go-connections v0.6.0 // indirect
3135
github.com/docker/go-units v0.5.0 // indirect
36+
github.com/ebitengine/purego v0.9.1 // indirect
3237
github.com/felixge/httpsnoop v1.0.4 // indirect
3338
github.com/go-asn1-ber/asn1-ber v1.5.8-0.20250403174932-29230038a667 // indirect
34-
github.com/go-logr/logr v1.4.2 // indirect
39+
github.com/go-logr/logr v1.4.3 // indirect
3540
github.com/go-logr/stdr v1.2.2 // indirect
36-
github.com/go-ole/go-ole v1.2.6 // indirect
37-
github.com/gogo/protobuf v1.3.2 // indirect
41+
github.com/go-ole/go-ole v1.3.0 // indirect
3842
github.com/google/uuid v1.6.0 // indirect
43+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.4 // indirect
3944
github.com/jackc/pgpassfile v1.0.0 // indirect
4045
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
41-
github.com/jackc/pgx/v5 v5.7.3 // indirect
46+
github.com/jackc/pgx/v5 v5.8.0 // indirect
4247
github.com/jackc/puddle/v2 v2.2.2 // indirect
43-
github.com/klauspost/compress v1.17.4 // indirect
44-
github.com/kr/text v0.2.0 // indirect
45-
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
46-
github.com/magiconair/properties v1.8.7 // indirect
48+
github.com/klauspost/compress v1.18.2 // indirect
49+
github.com/lufia/plan9stats v0.0.0-20251013123823-9fd1530e3ec3 // indirect
50+
github.com/magiconair/properties v1.8.10 // indirect
4751
github.com/moby/docker-image-spec v1.3.1 // indirect
52+
github.com/moby/go-archive v0.2.0 // indirect
4853
github.com/moby/patternmatcher v0.6.0 // indirect
49-
github.com/moby/sys/sequential v0.5.0 // indirect
50-
github.com/moby/sys/user v0.3.0 // indirect
54+
github.com/moby/sys/sequential v0.6.0 // indirect
55+
github.com/moby/sys/user v0.4.0 // indirect
5156
github.com/moby/sys/userns v0.1.0 // indirect
52-
github.com/moby/term v0.5.0 // indirect
53-
github.com/morikuni/aec v1.0.0 // indirect
57+
github.com/moby/term v0.5.2 // indirect
58+
github.com/morikuni/aec v1.1.0 // indirect
5459
github.com/opencontainers/go-digest v1.0.0 // indirect
55-
github.com/opencontainers/image-spec v1.1.0 // indirect
60+
github.com/opencontainers/image-spec v1.1.1 // indirect
5661
github.com/pkg/errors v0.9.1 // indirect
5762
github.com/pmezard/go-difflib v1.0.0 // indirect
58-
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
59-
github.com/rogpeppe/go-internal v1.14.1 // indirect
60-
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
61-
github.com/shoenig/go-m1cpu v0.1.6 // indirect
63+
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
64+
github.com/shirou/gopsutil/v4 v4.25.12 // indirect
6265
github.com/sirupsen/logrus v1.9.3 // indirect
63-
github.com/testcontainers/testcontainers-go v0.35.0 // indirect
64-
github.com/tklauser/go-sysconf v0.3.12 // indirect
65-
github.com/tklauser/numcpus v0.6.1 // indirect
66-
github.com/yusufpapurcu/wmi v1.2.3 // indirect
67-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
68-
go.opentelemetry.io/otel v1.24.0 // indirect
69-
go.opentelemetry.io/otel/metric v1.24.0 // indirect
70-
go.opentelemetry.io/otel/trace v1.24.0 // indirect
71-
golang.org/x/crypto v0.36.0 // indirect
72-
golang.org/x/sync v0.12.0 // indirect
73-
golang.org/x/sys v0.32.0 // indirect
74-
golang.org/x/text v0.23.0 // indirect
75-
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect
66+
github.com/testcontainers/testcontainers-go v0.40.0 // indirect
67+
github.com/tklauser/go-sysconf v0.3.16 // indirect
68+
github.com/tklauser/numcpus v0.11.0 // indirect
69+
github.com/yusufpapurcu/wmi v1.2.4 // indirect
70+
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
71+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.64.0 // indirect
72+
go.opentelemetry.io/otel v1.39.0 // indirect
73+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.39.0 // indirect
74+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.39.0 // indirect
75+
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.39.0 // indirect
76+
go.opentelemetry.io/otel/metric v1.39.0 // indirect
77+
go.opentelemetry.io/otel/sdk v1.39.0 // indirect
78+
go.opentelemetry.io/otel/trace v1.39.0 // indirect
79+
go.opentelemetry.io/proto/otlp v1.9.0 // indirect
80+
golang.org/x/crypto v0.46.0 // indirect
81+
golang.org/x/net v0.48.0 // indirect
82+
golang.org/x/sync v0.19.0 // indirect
83+
golang.org/x/sys v0.40.0 // indirect
84+
golang.org/x/text v0.33.0 // indirect
85+
google.golang.org/genproto/googleapis/api v0.0.0-20251222181119-0a764e51fe1b // indirect
86+
google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b // indirect
87+
google.golang.org/grpc v1.78.0 // indirect
88+
google.golang.org/protobuf v1.36.11 // indirect
7689
gopkg.in/yaml.v3 v3.0.1 // indirect
7790
)

0 commit comments

Comments
 (0)