zeta 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02f15040a2acf0e5a0b85b9d5a3aa02ff61e3aa4
4
- data.tar.gz: e5c2e9bbc3751567af03ef034b90f9e715672710
3
+ metadata.gz: cc1fa795152d2eafcd724bf92624b98e6a24c3c0
4
+ data.tar.gz: de69bbd58d346f4d8d23243b5aa487cf4dd75443
5
5
  SHA512:
6
- metadata.gz: fc605fed51ad16edcc90c4ed90bba8cd967c2a1b169d6ff2b5b558cd10886d4a51b31a5ec7a9b09bbdfecbb1421425e9d23dba457a55241d38287a81642e8fa0
7
- data.tar.gz: 8ed946c7a676e81c3d36a99bdb7b904498f1c71138c7b4c5ccd229485832f84a245bc8f9c38a5f6f98fe008a101e8ef99036183aa139ac1e811ba73557869963
6
+ metadata.gz: 26af9adcdd2b7a9de94f10a21261ad15a5ea3784c68cd05c462fbd3c64c5f0ab1a0bf2e279018ce8448b75f439b84706defc376467158738b1a908b09f204304
7
+ data.tar.gz: 49ade2a3d0b12551600eccd0599b91e6254d9deefeeca6f22a82158240ebf3e6225ba11500377dcc29680fc303cb3c6d6ca73e1a05e1812575a674914331774d
data/CHANGELOG.markdown CHANGED
@@ -1,6 +1,10 @@
1
+ # 0.4.0 (30-Oct-15)
2
+ - update lacerda which uses ServiceName::Object in favor of ServiceName:Object
3
+
1
4
  # 0.3.0 (29-Oct-15)
2
5
  - forward published/consume object validation method to the current service in the infrastructure
3
6
  - forward wrapped consume object creation to the current service
7
+ - use HTTP_USER and HTTP_PASSWORD instead of GITHUB_USER and GITHUB_TOKEN
4
8
 
5
9
  # 0.2.5 (28-Oct-15)
6
10
  - better CLI help
data/README.md CHANGED
@@ -7,11 +7,11 @@
7
7
  TLDR:
8
8
  - each service defines which objects it publishes or consumes
9
9
  - these contracts are formatted in human readable markdown
10
- - you never have to know/care about other services or repositories
10
+ - you never have to check out other services' repositories
11
11
 
12
12
  Zeta will:
13
- - know the rest of your infrastructure and fetches the contracts of all other services
14
- - alert you if your change in service X breaks service Y
13
+ - know the rest of your infrastructure and fetch the contracts of all other services
14
+ - alert you if your change breaks the expectactions of other services
15
15
  ```
16
16
 
17
17
  In an infrastructure where many services are talking with each other, it's sometimes hard to know **how changes in one service affect other services**, as each service often just knows about itself. Even if local tests pass, you can't know what other services might be affected when you make changes to a service.
@@ -23,7 +23,7 @@ In an infrastructure where many services are talking with each other, it's somet
23
23
 
24
24
  Let's imagine an imaginary chat app that is split up into three independent services that communicate via a message broker:
25
25
 
26
- - **MessageService** keeps track of the state of to do items
26
+ - **MessageService** keeps track off storing messages
27
27
  - **SearchService** makes your chat history searchable
28
28
  - **NotificationService**: sends an email when a private message is received
29
29
 
@@ -33,7 +33,7 @@ An intern is asked to implement a feature that allows one message to be sent to
33
33
 
34
34
  😱But **THE INTERN JUST BROKE THE NOTIFICATION SERVICE** because it depends on the `recipient_id` property 😱
35
35
 
36
- Wouldn't it be nice of some test local to the **MessageService** repository to tell the poorintern that removing the `recipient_id` property breaks the expectations other services have of the *MessageService* BEFORE they deploy?
36
+ Wouldn't it be nice of some test local to the **MessageService** repository to tell the poor intern that removing the `recipient_id` property breaks the expectations other services have regarding the *MessageService* BEFORE the intern hits the red deploy button?
37
37
 
38
38
 
39
39
  ## Yes, it would!
@@ -46,8 +46,8 @@ Each service has to contain two files in order for *Zeta* to do its job:
46
46
  These are simple markdown files in the wonderful [MSON](https://github.com/apiaryio/mson) format. Let's look at the contracts dir of **MessageService**, shall we?
47
47
 
48
48
  ### A publish specification:
49
+ `contracts/publish.mson:`
49
50
  ```shell
50
- /home/dev/message-service$ cat contracts/publish.mson
51
51
  # Data Structures
52
52
  This file defines what MessageService may publish.
53
53
 
@@ -62,12 +62,12 @@ This file defines what MessageService may publish.
62
62
  So far so good. This way *MessageService* can tell the world what exactly it means when a `Message` object is published. Much the same, the *NotificationService* could define which properties of a `Message` object from the `MessageService` it is actually interested in:
63
63
 
64
64
  ### A consume specification:
65
+ `contracts/consume.mson:`
65
66
  ```shell
66
- /home/dev/notification-service$ cat contracts/consume.mson
67
67
  # Data Structures
68
68
  We just consume one object type, and it comes from the MessageService. Check it out!
69
69
 
70
- # MessageService:Message
70
+ # MessageService::Message
71
71
  - sender_id: (number, required)
72
72
  - recipient_id: (number, required)
73
73
  ```
@@ -84,7 +84,7 @@ As you can see, this consumer expects the `recipient_id` property to be present
84
84
  ## Getting started
85
85
 
86
86
  ### 1. Installation
87
- First, add *Zeta* to your `Gemfile` or install manually:
87
+ Even though it does not matter what programming languages your services are written in, you'll need ruby to run Zeta. To install, add *Zeta* to your `Gemfile` or install it manually:
88
88
 
89
89
  ```shell
90
90
  $ gem install zeta
@@ -135,10 +135,11 @@ production:
135
135
 
136
136
  ```
137
137
 
138
- You typically just create the above file once and then don't touch it anymore. If that file is in a private repository (that would be a good idea), make sure you `export GITHUB_USER=youruser` and `GITHUB_TOKEN=yourtoken` and *Zeta* will use that.
138
+ You typically just create the above file once in each project and then don't touch it anymore. Whenever a new service gets added to or removed from the infrastructure, you just update the central infrastructure configuration. The what? Central infrastructure configuration? Oh, look:
139
139
 
140
- Here's how `github.com/jensmander/zeta-config/infrastructure/master.yml` might look in our example above:
140
+ Here's how the infrastructure configuration file might look for our example above:
141
141
 
142
+ `git@github.com:jensmander/zeta-config/infrastructure/master.yml:`
142
143
  ```yaml
143
144
  MessageService:
144
145
  github:
@@ -159,10 +160,15 @@ NotificationService:
159
160
 
160
161
  Whenever you add a service to the infrastructure, you just add it to this central file and all existing services will automatically know about your new service.
161
162
 
163
+ ### 3. Authentication
162
164
 
163
- ### 3. Usage
165
+ If your infrastruture configuration file is HTTP Basic auth protected, or in a private repository on github (that would be a good idea), make sure you `export HTTP_USER=username` and `HTTP_PASSWORD=secret` and *Zeta* will use that. If you host on github, the use your username and generate an API token to use as the password.
164
166
 
165
- ```shell
167
+ ### 4. Usage: Command line
168
+
169
+ Zeta comes with a `zeta` command that takes care of all the things:
170
+
171
+ ```
166
172
  Usage: zeta [options] full_check|fetch_remote_contracts|update_own_contracts|validate
167
173
 
168
174
  Specific options:
@@ -183,9 +189,9 @@ $ zeta -e development full_check
183
189
 
184
190
  The above command performs the following three steps:
185
191
 
186
- 1. Fetch all contracts from remote repositories and put them into the cache directory configured above
187
- 2. Copy the current services contracts (that you might have changed) into the cache directory
188
- 3. Validate all contracts (i.e. make sure that every publishing service satisfies its consumers)
192
+ 1. **Fetch all contracts** from remote repositories and put them into the cache directory configured above
193
+ 2. **Copy the current service's contracts** which you might have changed into the contracts cache directory
194
+ 3. **Validate all contracts** (i.e. make sure that every publishing service satisfies its consumers)
189
195
 
190
196
  The above commands can also be run in isolation:
191
197
 
@@ -206,3 +212,25 @@ $ zeta -e development update_own_contracts validate
206
212
  ```
207
213
 
208
214
  Otherwise it will exit with an error and display any contract violations in JSON.
215
+
216
+ ### 5. Usage: in ruby
217
+
218
+ If you use *Zeta* in ruby, it will automatically know the current service, i.e. the one that it's running in. It will create a singleton `Lacerda::Infrastructure` instance from the [Lacerda gem](https://github.com/moviepilot/Lacerda), which gives you access to a bunch of interesting functions. If you're using [pry](https://github.com/pry/pry), go ahead and do a quick `ls Zeta` and you will something like this, likely outdated, list:
219
+
220
+ ```ruby
221
+ [1] pry(main)> ls Zeta
222
+ Zeta.methods:
223
+ cache_dir current_service update_own_contracts
224
+ config env validate_object_to_consume
225
+ config_file errors validate_object_to_consume!
226
+ consume_object infrastructure validate_object_to_publish
227
+ contracts_fulfilled? update_contracts validate_object_to_publish!
228
+ [2] pry(main)>
229
+ ```
230
+
231
+ Each and every one of these goes directly to your instance `Lacerda::Infrastructure`, as defined by `config/zeta.yml`. Feel free to explore them a bit, but the ones' that might be of most interest are:
232
+
233
+ - `Zeta.validate_object_to_publish('Post', data_to_send)` makes sure that the content in `data_to_send` conforms to your 'Post' specification in your local `publish.mson`
234
+ - `Zeta.consume_object('MessageService::Message', received_data)` will give you an instance of the [Blumquist](https://github.com/moviepilot/blumquist) class, which is an obect that has getters for all properties you specified in `consume.mson`
235
+
236
+ If you use these in your servies, they will help keeping the publish and consume specifications in sync with what's actually happening in the code.
data/circle.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  machine:
2
2
  ruby:
3
- version: 2.2.1
3
+ version: '1.9'
@@ -30,7 +30,7 @@ class Zeta::LocalOrRemoteFile
30
30
  end
31
31
 
32
32
  def self.http_get(url, verbose)
33
- masked_url = ENV['GITHUB_TOKEN'].blank? ? url : url.sub(ENV['GITHUB_TOKEN'], '***')
33
+ masked_url = ENV['HTTP_PASSWORD'].blank? ? url : url.sub(ENV['HTTP_PASSWORD'], '***')
34
34
  print "GET #{masked_url}... " if verbose
35
35
  result = HTTParty.get url
36
36
  raise "Error #{result.code}" unless result.code == 200
@@ -45,6 +45,8 @@ class Zeta::LocalOrRemoteFile
45
45
  !!@options[:verbose]
46
46
  end
47
47
 
48
+ # In order not to have git as a dependency, we'll fetch from
49
+ # raw.githubusercontent.com as long as we get away with it.
48
50
  def github_url
49
51
  repo = @options[:github][:repo]
50
52
  branch = @options[:github][:branch]
@@ -52,8 +54,10 @@ class Zeta::LocalOrRemoteFile
52
54
  file = @options[:file]
53
55
 
54
56
  uri = [branch, path, file].compact.join('/')
55
- if u = ENV['GITHUB_USER'] and t = ENV['GITHUB_TOKEN']
56
- "https://#{u}:#{t}@raw.githubusercontent.com/#{repo}/#{uri}"
57
+ u = ENV['HTTP_USER']
58
+ p = ENV['HTTP_PASSWORD']
59
+ if p
60
+ "https://#{u}:#{p}@raw.githubusercontent.com/#{repo}/#{uri}"
57
61
  else
58
62
  "https://raw.githubusercontent.com/#{repo}/#{uri}"
59
63
  end
data/lib/zeta/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Zeta
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/zeta.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
 
21
21
  spec.add_runtime_dependency 'rake', '~> 10.2'
22
- spec.add_runtime_dependency 'lacerda', '~> 0.5'
22
+ spec.add_runtime_dependency 'lacerda', '~> 0.7'
23
23
  spec.add_runtime_dependency 'activesupport'
24
24
  spec.add_runtime_dependency 'httparty', '~> 0.13'
25
25
  spec.add_runtime_dependency 'colorize'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zeta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jannis Hermanns
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-29 00:00:00.000000000 Z
11
+ date: 2015-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.5'
33
+ version: '0.7'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.5'
40
+ version: '0.7'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: activesupport
43
43
  requirement: !ruby/object:Gem::Requirement