Skip to content

Commit

Permalink
Merge pull request #1281 from openmeterio/feat/notification-service
Browse files Browse the repository at this point in the history
feat: notification-service
  • Loading branch information
turip authored Aug 1, 2024
2 parents a80830e + a95a0ac commit 0ebba16
Show file tree
Hide file tree
Showing 11 changed files with 822 additions and 11 deletions.
13 changes: 13 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@
"--telemetry-address",
":10002"
]
},
{
"name": "Launch Notification Service",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/cmd/notification-service",
"args": [
"--config",
"${workspaceFolder}/config.yaml",
"--telemetry-address",
":10003"
]
}
]
}
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ RUN xx-verify /usr/local/bin/openmeter-sink-worker
RUN go build -ldflags "-linkmode external -extldflags \"-static\" -X main.version=${VERSION}" -tags musl -o /usr/local/bin/openmeter-balance-worker ./cmd/balance-worker
RUN xx-verify /usr/local/bin/openmeter-balance-worker

# Build balance-worker binary
RUN go build -ldflags "-linkmode external -extldflags \"-static\" -X main.version=${VERSION}" -tags musl -o /usr/local/bin/openmeter-notification-service ./cmd/notification-service
RUN xx-verify /usr/local/bin/openmeter-notification-service


FROM gcr.io/distroless/base-debian11:latest@sha256:ac69aa622ea5dcbca0803ca877d47d069f51bd4282d5c96977e0390d7d256455 AS distroless

Expand All @@ -47,6 +51,7 @@ COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /usr/local/bin/openmeter /usr/local/bin/
COPY --from=builder /usr/local/bin/openmeter-sink-worker /usr/local/bin/
COPY --from=builder /usr/local/bin/openmeter-balance-worker /usr/local/bin/
COPY --from=builder /usr/local/bin/openmeter-notification-service /usr/local/bin/
COPY --from=builder /usr/local/src/openmeter/go.* /usr/local/src/openmeter/

CMD openmeter
Expand All @@ -58,6 +63,7 @@ COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /usr/local/bin/openmeter /usr/local/bin/
COPY --from=builder /usr/local/bin/openmeter-sink-worker /usr/local/bin/
COPY --from=builder /usr/local/bin/openmeter-balance-worker /usr/local/bin/
COPY --from=builder /usr/local/bin/openmeter-notification-service /usr/local/bin/
COPY --from=builder /usr/local/src/openmeter/go.* /usr/local/src/openmeter/

CMD openmeter
Expand All @@ -71,6 +77,7 @@ SHELL ["/bin/bash", "-c"]
COPY --from=builder /usr/local/bin/openmeter /usr/local/bin/
COPY --from=builder /usr/local/bin/openmeter-sink-worker /usr/local/bin/
COPY --from=builder /usr/local/bin/openmeter-balance-worker /usr/local/bin/
COPY --from=builder /usr/local/bin/openmeter-notification-service /usr/local/bin/
COPY --from=builder /usr/local/src/openmeter/go.* /usr/local/src/openmeter/

CMD openmeter
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ build-balance-worker: ## Build balance-worker binary
$(call print-target)
go build -o build/balance-worker ./cmd/balance-worker

.PHONY: build-notification-service
build-notification-service: ## Build notification-service binary
$(call print-target)
go build -o build/notification-service ./cmd/notification-service

config.yaml:
cp config.example.yaml config.yaml

Expand All @@ -64,6 +69,12 @@ balance-worker: ## Run balance-worker
$(call print-target)
air -c ./cmd/balance-worker/.air.toml

.PHONY: notification-service
notification-service: ## Run notification-service
@ if [ config.yaml -ot config.example.yaml ]; then diff -u config.yaml config.example.yaml || (echo "!!! The configuration example changed. Please update your config.yaml file accordingly (or at least touch it). !!!" && false); fi
$(call print-target)
air -c ./cmd/notification-service/.air.toml

.PHONY: etoe
etoe: ## Run e2e tests
$(call print-target)
Expand Down
44 changes: 44 additions & 0 deletions cmd/notification-service/.air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"

[build]
args_bin = ["--config", "./config.yaml", "--telemetry-address", ":10002"]
bin = "./tmp/openmeter-notification-service"
cmd = "go build -o ./tmp/openmeter-notification-service ./cmd/notification-service"
delay = 0
exclude_dir = ["assets", "ci", "deploy", "docs", "examples", "testdata", "quickstart", "tmp", "vendor", "api/client", "node_modules"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html", "yml", "yaml", "sql", "json"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
rerun = false
rerun_delay = 500
send_interrupt = true
stop_on_error = false

[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"

[log]
main_only = false
time = false

[misc]
clean_on_exit = false

[screen]
clear_on_rebuild = false
keep_scroll = true
Loading

0 comments on commit 0ebba16

Please sign in to comment.