Skip to content

Commit

Permalink
apache-pulsar 2.8.0 (new formula)
Browse files Browse the repository at this point in the history
* New Formula: Apache Pulsar
  This commit adds a formula for the Apache Pulsar message broker
  (https://pulsar.apache.org/). The broker will operate in its minimal/
  default "standalone" mode when started by this formula, which is
  roughly equivalent to the behavior of ZooKeeper and other similar
  formulae.
* Address linter errors
* Address reviewer comments
* Attempt to resolve CI failures: make /etc path
* try moving directory creation to before tar command
* Remove asterisk for config symlink
* Remove non-optional cross compiled PPC file
* Add protobuf as build dependency
* Attempt to force x86_64 architecture to get m1 build working
* Fix linter issues
* Try overriding protoc command
* Fix trailing new line
* Try a newer version of protoc
* Try overriding grpc version as well
* Give up on versioning grpc and proto forward
* Constrain arch
* Constrain arch
* Support building from HEAD properly
* Address reviewer comments
* Link to upstream packaging issue and force JVM version
* Restore JVM version pin for build
* Reviewer suggestion: use utility fucntion for java home
* Fix mistaken non-string use of java_home_env
* Address reviewer comments
* Apply suggestions from code review
* Move log creation to postinstall
* Update Formula/apache-pulsar.rb

Closes #83238.

Co-authored-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
Co-authored-by: Zac Bentley <zbentley@users.noreply.github.com>
Signed-off-by: Carlo Cabrera <30379873+carlocab@users.noreply.github.com>
Signed-off-by: BrewTestBot <1589480+BrewTestBot@users.noreply.github.com>
  • Loading branch information
3 people authored and BrewTestBot committed Sep 16, 2021
1 parent 6b01e3a commit 9e70f4b
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions Formula/apache-pulsar.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
class ApachePulsar < Formula
desc "Cloud-native distributed messaging and streaming platform"
homepage "https://pulsar.apache.org/"
url "https://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=pulsar/pulsar-2.8.0/apache-pulsar-2.8.0-src.tar.gz"
mirror "https://archive.apache.org/dist/pulsar/pulsar-2.8.0/apache-pulsar-2.8.0-src.tar.gz"
sha256 "0e161a81c62c7234c1e0c243bb6fe30046ec1cd01472618573ecdc2a73b1163b"
license "Apache-2.0"
head "https://github.com/apache/pulsar.git", branch: "master"

depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "cppunit" => :build
depends_on "libtool" => :build
depends_on "maven" => :build
depends_on "pkg-config" => :build
depends_on "protobuf" => :build
depends_on arch: :x86_64
depends_on "openjdk@11"

def install
# Missing executable permission reported upstream: https://github.com/apache/pulsar/issues/11833
chmod "+x", "src/rename-netty-native-libs.sh"

with_env("TMPDIR" => buildpath, **Language::Java.java_home_env("11")) do
system "mvn", "-X", "clean", "package", "-DskipTests", "-Pcore-modules"
end

built_version = if build.head?
# This script does not need any particular version of py3 nor any libs, so both
# brew-installed python and system python will work.
Utils.safe_popen_read("python3", "src/get-project-version.py").strip
else
version
end

binpfx = "apache-pulsar-#{built_version}"
system "tar", "-xf", "distribution/server/target/#{binpfx}-bin.tar.gz"
libexec.install "#{binpfx}/bin", "#{binpfx}/lib", "#{binpfx}/instances", "#{binpfx}/conf"
(libexec/"lib/presto/bin/procname/Linux-ppc64le").rmtree
pkgshare.install "#{binpfx}/examples", "#{binpfx}/licenses"
(etc/"pulsar").install_symlink libexec/"conf"

libexec.glob("bin/*") do |path|
if !path.fnmatch?("*common.sh") && !path.directory?
bin_name = path.basename
(bin/bin_name).write_env_script libexec/"bin"/bin_name, Language::Java.java_home_env("11")
end
end
end

def post_install
(var/"log/pulsar").mkpath
end

service do
run [bin/"pulsar", "standalone"]
log_path var/"log/pulsar/output.log"
error_log_path var/"log/pulsar/error.log"
end

test do
fork do
exec bin/"pulsar", "standalone", "--zookeeper-dir", "#{testpath}/zk", " --bookkeeper-dir", "#{testpath}/bk"
end
# The daemon takes some time to start; pulsar-client will retry until it gets a connection, but emit confusing
# errors until that happens, so sleep to reduce log spam.
sleep 15

output = shell_output("#{bin}/pulsar-client produce my-topic --messages 'hello-pulsar'")
assert_match "1 messages successfully produced", output
output = shell_output("#{bin}/pulsar initialize-cluster-metadata -c a -cs localhost -uw localhost -zk localhost")
assert_match "Cluster metadata for 'a' setup correctly", output
end
end

0 comments on commit 9e70f4b

Please sign in to comment.