This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defproject todo-rest "0.1.0-SNAPSHOT" | |
| :description "FIXME: write description" | |
| :url "http://example.com/FIXME" | |
| :license {:name "Eclipse Public License" | |
| :url "http://www.eclipse.org/legal/epl-v10.html"} | |
| :dependencies [[org.clojure/clojure "1.8.0"] | |
| [ring "1.5.0"] | |
| [compojure "1.5.1"] | |
| [ring/ring-json "0.4.0"] | |
| [org.clojure/java.jdbc "0.6.1"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns todo-rest.core | |
| (:require [ring.adapter.jetty :as jetty] | |
| [ring.middleware.reload :refer [wrap-reload]] | |
| [ring.middleware.json :refer [wrap-json-response wrap-json-params]] | |
| [compojure.core :refer [defroutes context GET POST PUT DELETE]] | |
| [compojure.route :refer [not-found]] | |
| [clojure.java.jdbc :as jdbc]) | |
| (:import com.mchange.v2.c3p0.ComboPooledDataSource) | |
| (:gen-class)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - hosts: localhost | |
| become: yes | |
| connection: local | |
| tasks: | |
| - apt: | |
| package: openjdk-8-jdk-headless | |
| update_cache: yes | |
| cache_valid_time: 3600 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "chef/log" | |
| def alter!(directory, zookeeper, topic, partitions) | |
| cmd = %W( | |
| #{directory}/bin/kafka-topics.sh | |
| --zookeeper #{zookeeper} | |
| --alter | |
| --topic #{topic} | |
| --partitions #{partitions} | |
| ).join(" ") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| action :update do | |
| alter! new_resource.directory, | |
| new_resource.zookeeper, | |
| new_resource.topic, | |
| new_resource.partitions | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| action :create do | |
| # calls the block if current_resource does not exist | |
| # or values are different from current_resource | |
| converge_if_changed do | |
| if current_resource | |
| action_update | |
| else | |
| converge_by "Create topic #{new_resource.topic}" do | |
| create! new_resource.directory, | |
| new_resource.zookeeper, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| load_current_value do | |
| current_partitions, current_replicas = list(directory, zookeeper, topic) | |
| .values_at *%w(partitions replicas) | |
| current_value_does_not_exist! unless current_partitions && current_replicas | |
| partitions current_partitions | |
| replicas current_replicas | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def list(directory, zookeeper, topic) | |
| cmd = %W( | |
| #{directory}/bin/kafka-topics.sh | |
| --zookeeper #{zookeeper} | |
| --describe | |
| --topic #{topic} | |
| ).join(" ") | |
| result = shell_out(cmd).stdout | |
| extract = ->(a) { a && a.to_i } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "spec_helper" | |
| context "test_example" do | |
| let(:chef_conf) do | |
| ChefSpec::SoloRunner.new cookbook_path: %w(./test/cookbooks ../), # import test and example cookbook | |
| step_into: %w(example_topic) # dive inside example_topic | |
| end | |
| let(:shellout) { double("shellout") } # setup shellout double |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name "test_example" | |
| maintainer "The Authors" | |
| maintainer_email "[email protected]" | |
| license "all_rights" | |
| description "Installs/Configures test" | |
| long_description "Installs/Configures test" | |
| version "0.1.0" | |
| depends "example" # example cookbook dependency |