Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ services:
- "3000:3000"
volumes:
- ./:/root/warchest
security_opt:
- seccomp:unconfined
environment:
- NODE_ENV=development
- BE_DATABASE_URL=postgres://postgres:password@postgres-be:5432/warchest
- MM_DATABASE_URL=postgres://postgres:password@postgres-mm:5432/money_module
- TIGERBEETLE_ADDRESS=tigerbeetle:3000
- TIGERBEETLE_ADDRESS=172.20.0.10:3000
networks:
- warchest-network
depends_on:
Expand Down Expand Up @@ -57,13 +59,15 @@ services:
retries: 5

tigerbeetle:
build:
context: ./money-module/tigerbeetle
dockerfile: Dockerfile
image: ghcr.io/tigerbeetle/tigerbeetle
entrypoint: ["/bin/sh"]
command: "/start.sh"
networks:
- warchest-network
warchest-network:
ipv4_address: 172.20.0.10
volumes:
- tigerbeetle_data:/data
- ./money-module/tigerbeetle/start.sh:/start.sh
security_opt:
- seccomp:unconfined

Expand All @@ -75,3 +79,6 @@ volumes:
networks:
warchest-network:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/24 # Define the range (e.g., 172.20.0.1 to 172.20.0.254)
2 changes: 2 additions & 0 deletions money-module/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module money-module

go 1.22.2

require github.com/tigerbeetle/tigerbeetle-go v0.17.1
2 changes: 2 additions & 0 deletions money-module/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/tigerbeetle/tigerbeetle-go v0.17.1 h1:jrpTigDx/UN7+xAlV14H6er6AUR+CstYALjZZATJtJc=
github.com/tigerbeetle/tigerbeetle-go v0.17.1/go.mod h1:d6G7n4OlD7GLHd62x0VlWPXeI/L0SoNNTfm/ee24GJI=
22 changes: 20 additions & 2 deletions money-module/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
package main

import "fmt"
import (
"log"
"os"

tb "github.com/tigerbeetle/tigerbeetle-go"
)

func main() {
fmt.Println("Hello, World!")
tbAddress := os.Getenv("TIGERBEETLE_ADDRESS")

if len(tbAddress) == 0 {
tbAddress = "3000"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(TiGoStyle) I think this is something we should fully check our preconditions for. (i.e I think money-module should instantly fail if the address isn't numeric, and nor a valid port number etc (TiGoStyle))

}

client, err := tb.NewClient(tb.ToUint128(0), []string{tbAddress})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Is there a way to use var client tb.Client, var err error. (Maybe just declare on line above?) (TiGoStyle shit). I think this is fine in this case because this statement cannot be misinfered and will be hidden in the init anyways


if err != nil {
log.Printf("Error creating client: %s", err)
return
}

defer client.Close()
}
Comment on lines 1 to 25
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move these to an init and fini functions please.

13 changes: 0 additions & 13 deletions money-module/money-module/main.go

This file was deleted.

18 changes: 0 additions & 18 deletions money-module/tigerbeetle/Dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions money-module/tigerbeetle/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e
DATA_FILE="${TIGERBEETLE_DATA_FILE:-/data/0_0.tigerbeetle}"

if [ ! -f "$DATA_FILE" ]; then
tigerbeetle format --cluster=0 --replica=0 --replica-count=1 --development "$DATA_FILE"
/tigerbeetle format --cluster=0 --replica=0 --replica-count=1 --development "$DATA_FILE"
fi

exec tigerbeetle start --development --addresses=0.0.0.0:3000 "$DATA_FILE"
exec /tigerbeetle start --development --addresses=0.0.0.0:3000 "$DATA_FILE"
Comment thread
keyvjin marked this conversation as resolved.
Loading