Merge pull request #206954 from Homebrew/bump-gollama-1.28.13
[homebrew-core.git] / Formula / d / dtm.rb
blob92543fb1df6b0fec9c316ab0dc0d593727e0c084
1 class Dtm < Formula
2   desc "Cross-language distributed transaction manager"
3   homepage "https://en.dtm.pub/"
4   url "https://github.com/dtm-labs/dtm/archive/refs/tags/v1.19.0.tar.gz"
5   sha256 "11340c32e810dfd463953bca0a5f5a2c41a88c35782efc2ab70cfa78733fa823"
6   license "BSD-3-Clause"
8   bottle do
9     sha256 cellar: :any_skip_relocation, arm64_sequoia: "818718052e97df9ffcfed8c29a8f7bbce0e5302c6639c208c3c080d188ce75c6"
10     sha256 cellar: :any_skip_relocation, arm64_sonoma:  "818718052e97df9ffcfed8c29a8f7bbce0e5302c6639c208c3c080d188ce75c6"
11     sha256 cellar: :any_skip_relocation, arm64_ventura: "818718052e97df9ffcfed8c29a8f7bbce0e5302c6639c208c3c080d188ce75c6"
12     sha256 cellar: :any_skip_relocation, sonoma:        "cb8953792e5ca9d7edd4f56547f3f333ff6bb34de276f60781edd57acedc1288"
13     sha256 cellar: :any_skip_relocation, ventura:       "cb8953792e5ca9d7edd4f56547f3f333ff6bb34de276f60781edd57acedc1288"
14     sha256 cellar: :any_skip_relocation, x86_64_linux:  "a2def5327f55d8f789fa34bbe6ad73606bbe2807d42a59026f04130456fac0cb"
15   end
17   depends_on "go" => :build
19   def install
20     system "go", "build", *std_go_args(ldflags: "-s -w -X main.Version=v#{version}")
21     system "go", "build", *std_go_args(ldflags: "-s -w", output: bin/"dtm-qs"), "qs/main.go"
22   end
24   test do
25     assert_match "dtm version: v#{version}", shell_output("#{bin}/dtm -v")
27     http_port = free_port
28     grpc_port = free_port
30     dtm_pid = fork do
31       ENV["HTTP_PORT"] = http_port.to_s
32       ENV["GRPC_PORT"] = grpc_port.to_s
33       exec bin/"dtm"
34     end
35     # sleep to let dtm get its wits about it
36     sleep 5
37     metrics_output = shell_output("curl -s localhost:#{http_port}/api/metrics")
38     assert_match "# HELP dtm_server_info The information of this dtm server.", metrics_output
40     all_json = JSON.parse(shell_output("curl -s localhost:#{http_port}/api/dtmsvr/all"))
41     assert_equal 0, all_json["next_position"].length
42     assert all_json["next_position"].instance_of? String
43     assert_equal 0, all_json["transactions"].length
44     assert all_json["transactions"].instance_of? Array
45   ensure
46     # clean up the dtm process before we leave
47     Process.kill("HUP", dtm_pid)
48   end
49 end