Toggle navigation
Toggle navigation
This project
Loading...
Sign in
서승완
/
kappa
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Jose Diaz-Gonzalez
2016-06-12 03:56:16 -0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3f3e1050545483170f232d77e3b07aebe9457985
3f3e1050
1 parent
dd78bf19
simplify event source retrieval
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
19 deletions
kappa/context.py
kappa/context.py
View file @
3f3e105
...
...
@@ -22,10 +22,10 @@ import sys
import
kappa.function
import
kappa.restapi
import
kappa.event_source.dynamodb_stream
as
dynamodb_stream
import
kappa.event_source.kinesis
as
kinesis
import
kappa.event_source.s3
as
s3
import
kappa.event_source.sns
as
sns
import
kappa.event_source.dynamodb_stream
import
kappa.event_source.kinesis
import
kappa.event_source.s3
import
kappa.event_source.sns
import
kappa.policy
import
kappa.role
import
kappa.awsclient
...
...
@@ -168,27 +168,27 @@ class Context(object):
def
_create_event_sources
(
self
):
env_cfg
=
self
.
config
[
'environments'
][
self
.
environment
]
if
'event_sources'
in
env_cfg
:
if
'event_sources'
not
in
env_cfg
:
return
event_sources
=
env_cfg
.
get
(
'event_sources'
,
{})
if
not
event_sources
:
return
event_source_map
=
{
'dynamodb'
:
kappa
.
event_source
.
dynamodb_stream
.
DynamoDBStreamEventSource
,
'kinesis'
:
kappa
.
event_source
.
kinesis
.
KinesisEventSource
,
's3'
:
kappa
.
event_source
.
s3
.
S3EventSource
,
'sns'
:
kappa
.
event_source
.
sns
.
SNSEventSource
,
}
for
event_source_cfg
in
event_sources
:
_
,
_
,
svc
,
_
=
event_source_cfg
[
'arn'
]
.
split
(
':'
,
3
)
if
svc
==
'kinesis'
:
self
.
event_sources
.
append
(
kinesis
.
KinesisEventSource
(
self
,
event_source_cfg
))
elif
svc
==
's3'
:
event_source
=
event_source_map
.
get
(
svc
,
None
)
if
not
event_source
:
raise
ValueError
(
'Unknown event source: {0}'
.
format
(
event_source_cfg
[
'arn'
]))
self
.
event_sources
.
append
(
s3
.
S3EventSource
(
self
,
event_source_cfg
))
elif
svc
==
'sns'
:
self
.
event_sources
.
append
(
sns
.
SNSEventSource
(
self
,
event_source_cfg
))
elif
svc
==
'dynamodb'
:
self
.
event_sources
.
append
(
dynamodb_stream
.
DynamoDBStreamEventSource
(
self
,
event_source_cfg
))
else
:
msg
=
'Unknown event source:
%
s'
%
event_source_cfg
[
'arn'
]
raise
ValueError
(
msg
)
event_source
(
self
,
event_source_cfg
))
def
add_event_sources
(
self
):
for
event_source
in
self
.
event_sources
:
...
...
Please
register
or
login
to post a comment