Permalink
Browse files

added docs

  • Loading branch information...
1 parent 3af6b9a commit a07fde9594d6e8be6dd6f0ae5dc20da9b1cfccd8 @schorsch schorsch committed May 8, 2010
Showing with 109 additions and 2 deletions.
  1. +7 −0 .gitignore
  2. +20 −0 LICENSE
  3. +64 −0 README.rdoc
  4. +1 −1 VERSION
  5. +12 −1 lib/king_soa/registry.rb
  6. +1 −0 lib/king_soa/service.rb
  7. +4 −0 spec/server/app.rb
View
@@ -0,0 +1,7 @@
+*.sw?
+.DS_Store
+coverage
+rdoc
+pkg
+nbproject
+.rake_tasks
View
20 LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2009 Dirk Breuer
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -0,0 +1,64 @@
+= KingSoa
+
+Creating a SOA requires a centralized location to define all services within the
+SOA. Furthermore you want to know where those services live.
+
+== Tech details
+
+the soa registry is keeping a bunch of service objects which know where a method
+lives. Methods are classes with an self.execute method and can be located local,
+remote(http) or beeing put onto a queue
+
+
+
+== Install
+
+ gem install king_soa
+
+== Define services
+
+=== Low Level
+
+You can define services anywhere in your app and add them to the service
+registry.
+Be aware that the registry is a singleton, so that the rack middleware and your
+app are seeing the same :
+ # create the service
+ service = KingSoa::Service.new(:name=>:increment_usage,
+ :url=>'http://localhost:4567',
+ :auth_key=>'12345')
+ # register
+ KingSoa::Registry << service
+
+ # somewhere in your app just call your service method
+ KingSoa.increment_usage(12)
+
+A service name is always required. If the service is to be called remotely you
+must add a url and an auth_key.
+The transport is done via http calls, so to make it secure you should either use
+https in public or hide the servers somwhere on your farm.
+
+== Integration
+
+=== Rails
+
+
+=== Sinatra
+
+Take a look at spec/server/app where you can see a minimal sinatra implementation
+The base is just:
+ require 'king_soa'
+ use KingSoa::Rack::Middleware
+
+
+== Note on Patches/Pull Requests
+
+* Fork the project.
+* Make your feature addition or bug fix.
+* Add tests for it. This is important so I don't break it in a future version unintentionally.
+* Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
+* Send me a pull request. Bonus points for topic branches.
+
+== Copyright
+
+Copyright (c) 2010 Georg Leciejewski. See LICENSE for details.
View
@@ -1 +1 @@
-0.0.0
+0.0.1
View
@@ -19,8 +19,13 @@ def self.services
instance.services
end
+ # find a group of services identified by starting with the same string
+ #
+ def group(name)
+ instance.group(name)
+ end
############################################################################
- # Instance methods - not accessible => Singleton
+ # Instance methods - not directly accessible => Singleton
############################################################################
# returns all available methods
@@ -39,6 +44,12 @@ def [](service_name)
services.detect {|s| s.name == name }
end
+ def group(service_name)
+ name = service_name.to_sym
+# srvs = []
+ services.collect {|s| s.name[/^#{name}/] }
+ end
+
end
end
View
@@ -26,6 +26,7 @@ def execute(*args)
result = local_class ? local_class.send(:execute, *args) : call_remote(*args)
return result
end
+
def local_class
@local_class ||= begin
View
@@ -7,10 +7,14 @@
use KingSoa::Rack::Middleware
+#######################################
+# Somewhere in you app
+#
# setup test registry
service = KingSoa::Service.new(:name=>'soa_test_service', :auth_key=>'12345')
KingSoa::Registry << service
+# the class beeing called lokally
class SoaTestService
def self.execute(param1, param2, param3)

0 comments on commit a07fde9

Please sign in to comment.