Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
Noah
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Noah
Commits
b0c97789
Commit
b0c97789
authored
Mar 29, 2011
by
John E. Vincent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
agent.rb
parent
bfc8d7ff
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
8 additions
and
4 deletions
+8
-4
base_agent.rb
lib/noah/agents/base_agent.rb
+4
-2
http_agent.rb
lib/noah/agents/http_agent.rb
+1
-1
models.rb
lib/noah/models.rb
+1
-0
applications.rb
lib/noah/models/applications.rb
+2
-1
No files found.
lib/noah/agents/base_agent.rb
View file @
b0c97789
module
Noah::Agents
module
Noah::Agents
class
Base
class
Base
PREFIX
=
"base"
PREFIX
=
"base
://
"
NAME
=
"base-agent"
NAME
=
"base-agent"
DEFAULT_CONCURRENCY
=
1
DEFAULT_CONCURRENCY
=
1
NEEDS_TRANSFORM
=
false
def
self
.
inherited
(
base
)
def
self
.
inherited
(
base
)
Noah
::
Watchers
.
register_agent
(
base
)
Noah
::
Watchers
.
register_agent
(
base
)
...
@@ -11,12 +12,13 @@ module Noah::Agents
...
@@ -11,12 +12,13 @@ module Noah::Agents
end
end
def
notify
(
event
,
message
,
watch_list
)
def
notify
(
event
,
message
,
watch_list
)
logger
.
info
(
"
#{
self
.
class
}
worker initiated"
)
logger
.
info
(
"
#{
self
.
class
.
to_s
}
worker initiated"
)
worklist
=
[]
worklist
=
[]
watch_list
.
select
{
|
w
|
worklist
<<
w
[
:endpoint
]
if
(
w
[
:endpoint
]
=~
/^
#{
self
.
class
::
PREFIX
}
/
&&
event
=~
/^
#{
w
[
:pattern
]
}
/
)
}
watch_list
.
select
{
|
w
|
worklist
<<
w
[
:endpoint
]
if
(
w
[
:endpoint
]
=~
/^
#{
self
.
class
::
PREFIX
}
/
&&
event
=~
/^
#{
w
[
:pattern
]
}
/
)
}
if
worklist
.
size
>=
1
if
worklist
.
size
>=
1
logger
.
info
(
"Dispatching message to
#{
worklist
.
size
}
#{
self
.
class
.
to_s
}
endpoints"
)
logger
.
info
(
"Dispatching message to
#{
worklist
.
size
}
#{
self
.
class
.
to_s
}
endpoints"
)
EM
::
Iterator
.
new
(
worklist
,
self
.
class
::
DEFAULT_CONCURRENCY
).
each
do
|
ep
,
iter
|
EM
::
Iterator
.
new
(
worklist
,
self
.
class
::
DEFAULT_CONCURRENCY
).
each
do
|
ep
,
iter
|
ep
,
message
=
transform
(
ep
,
message
)
if
self
.
class
::
NEEDS_TRANSFORM
==
true
work!
(
ep
,
message
)
work!
(
ep
,
message
)
iter
.
next
iter
.
next
end
end
...
...
lib/noah/agents/http_agent.rb
View file @
b0c97789
...
@@ -5,7 +5,7 @@ module Noah::Agents
...
@@ -5,7 +5,7 @@ module Noah::Agents
PREFIX
=
"http://"
PREFIX
=
"http://"
NAME
=
self
.
class
.
to_s
NAME
=
self
.
class
.
to_s
DEFAULT_CONCURRENCY
=
50
0
DEFAULT_CONCURRENCY
=
50
def
work!
(
ep
,
message
)
def
work!
(
ep
,
message
)
logger
.
info
(
"Sending message to (
#{
ep
}
)"
)
logger
.
info
(
"Sending message to (
#{
ep
}
)"
)
...
...
lib/noah/models.rb
View file @
b0c97789
...
@@ -12,6 +12,7 @@ module Noah
...
@@ -12,6 +12,7 @@ module Noah
model
.
send
:attribute
,
:tags
model
.
send
:attribute
,
:tags
model
.
send
:index
,
:tag
model
.
send
:index
,
:tag
model
.
send
:attribute
,
:metadata
# removing this as it's simply redundant
# removing this as it's simply redundant
# model.after :save, :notify_via_redis_save
# model.after :save, :notify_via_redis_save
...
...
lib/noah/models/applications.rb
View file @
b0c97789
...
@@ -9,12 +9,13 @@ module Noah
...
@@ -9,12 +9,13 @@ module Noah
def
validate
def
validate
super
super
assert_present
:name
assert_present
:name
assert_unique
:name
end
end
def
to_hash
def
to_hash
arr
=
[]
arr
=
[]
configurations
.
sort
.
each
{
|
c
|
arr
<<
c
.
to_hash
}
configurations
.
sort
.
each
{
|
c
|
arr
<<
c
.
to_hash
}
super
.
merge
(
:name
=>
name
,
:c
reated_at
=>
created_at
,
:updated_at
=>
updated_at
,
:configurations
=>
arr
)
super
.
merge
(
:name
=>
name
,
:c
onfiguration
=>
arr
,
:created_at
=>
created_at
,
:updated_at
=>
updated_at
)
end
end
class
<<
self
class
<<
self
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment