This repository has been archived by the owner on Nov 10, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added yaml address book example, wrapped some potentially shared acce…
…ss calls with a mutex. Updated csv address book to actually read from a csv
- Loading branch information
1 parent
9277e7f
commit d1136a3
Showing
10 changed files
with
75 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'singleton' | ||
require 'thread' | ||
require 'yaml' | ||
|
||
class AddressBook | ||
include Singleton | ||
|
||
def initialize | ||
@servers = [] | ||
@mutex = Mutex.new | ||
end | ||
|
||
def configure(config) | ||
servers = YAML.load_file(config['file']) | ||
servers.each do |server| | ||
@servers << server | ||
end | ||
end | ||
|
||
# this method should return an array of hosts which this request is qualified to connect to. | ||
# which is determined based on the contents of the data passed | ||
def lookup_addresses(data) | ||
return @servers | ||
end | ||
end |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
panel: | ||
name: eventmachine | ||
name: rev | ||
max_connections: 1024 | ||
options: | ||
addr: 0.0.0.0 | ||
port: 8000 | ||
operator: | ||
name: random | ||
options: | ||
address_book: | ||
name: csv | ||
name: csv | ||
options: | ||
file: "examples/servers.csv" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
4.0,localhost,80 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
- :host: localhost | ||
:port: 80 |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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