cloud_powers 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -3
- data/.test.env.example +1 -0
- data/cloud_powers.gemspec +2 -2
- data/lib/cloud_powers/creatable.rb +15 -11
- data/lib/cloud_powers/example_objects.rb +88 -0
- data/lib/cloud_powers/helpers/lang_help.rb +33 -9
- data/lib/cloud_powers/helpers/logic_help.rb +28 -9
- data/lib/cloud_powers/helpers/path_help.rb +244 -34
- data/lib/cloud_powers/resource.rb +9 -5
- data/lib/cloud_powers/storage/bucket.rb +217 -0
- data/lib/cloud_powers/storage/local.rb +129 -0
- data/lib/cloud_powers/storage.rb +284 -12
- data/lib/cloud_powers/stubs/aws_stubs.rb +88 -10
- data/lib/cloud_powers/synapse/pipe/stream.rb +9 -11
- data/lib/cloud_powers/synapse/queue/board.rb +2 -1
- data/lib/cloud_powers/synapse/queue.rb +58 -1
- data/lib/cloud_powers/version.rb +1 -1
- data/lib/cloud_powers/zenv.rb +125 -60
- metadata +13 -11
- data/lib/cloud_powers/synapse/broadcast/broadcast.rb +0 -110
@@ -1,110 +0,0 @@
|
|
1
|
-
module Smash
|
2
|
-
module CloudPowers
|
3
|
-
module Synapse
|
4
|
-
module Broadcast
|
5
|
-
include Smash::CloudPowers::Helper
|
6
|
-
include Smash::CloudPowers::AwsResources
|
7
|
-
include Smash::CloudPowers::Zenv
|
8
|
-
|
9
|
-
# A simple Struct to bind the name with the arn of the topic
|
10
|
-
Channel = Struct.new(:set_name, :set_arn, :set_endpoint) do
|
11
|
-
include Smash::CloudPowers::Zenv
|
12
|
-
|
13
|
-
# Prefers the given arn but it can make a best guess if none is given
|
14
|
-
#
|
15
|
-
# Returns
|
16
|
-
# arn +String+ - arn for this resource
|
17
|
-
def arn
|
18
|
-
set_arn || "arn:aws:sns:#{zfind(:region)}:#{zfind(:accound_number)}:#{set_name}"
|
19
|
-
end
|
20
|
-
|
21
|
-
# Prefers the given name but it can parse the arn to find one
|
22
|
-
#
|
23
|
-
# Returns
|
24
|
-
# name +String+ - name for this resource
|
25
|
-
def name
|
26
|
-
set_name || set_arn.split(':').last
|
27
|
-
end
|
28
|
-
end # end Channel
|
29
|
-
#################
|
30
|
-
|
31
|
-
# Creates a connection point for 1..N nodes to create a connection with the Broadcast
|
32
|
-
# <b>Not Implimented</b>
|
33
|
-
#
|
34
|
-
# Parameters
|
35
|
-
# * channel +String+
|
36
|
-
#
|
37
|
-
# Notes
|
38
|
-
# This method is not implemented yet (V 0.2.7)
|
39
|
-
def create_distributor(channel)
|
40
|
-
sns.create_application_platform()
|
41
|
-
end
|
42
|
-
|
43
|
-
# Creates a point to connect to for information about a given topic
|
44
|
-
#
|
45
|
-
# Parameters
|
46
|
-
# * name +String+ - the name of the Channel/Topic to be created
|
47
|
-
#
|
48
|
-
# Returns
|
49
|
-
# +Broadcast::Channel+ - representing the created channel
|
50
|
-
def create_channel!(name)
|
51
|
-
resp = sns.create_topic(name: name)
|
52
|
-
Channel.new(nil, resp.topic_arn)
|
53
|
-
end
|
54
|
-
|
55
|
-
# Deletes a topic from SNS-land
|
56
|
-
#
|
57
|
-
# Parameters
|
58
|
-
# * channel <Broadcast::Channel>
|
59
|
-
def delete_channel!(channel)
|
60
|
-
sns.delete_topic(topic_arn: channel.arn)
|
61
|
-
end
|
62
|
-
|
63
|
-
# Creates a connection to the Broadcast so that new messages will be picked up
|
64
|
-
#
|
65
|
-
# Parameters channel <Broadcast::Channel>
|
66
|
-
def listen_on(channel)
|
67
|
-
sns.subscribe(
|
68
|
-
topic_arn: channel.arn,
|
69
|
-
protocol: 'application',
|
70
|
-
endpoint: channel.endpoint
|
71
|
-
)
|
72
|
-
end
|
73
|
-
|
74
|
-
# Lists the created topics in SNS.
|
75
|
-
#
|
76
|
-
# Returns results <Array
|
77
|
-
def real_channels
|
78
|
-
results = []
|
79
|
-
next_token = ''
|
80
|
-
loop do
|
81
|
-
resp = sns.list_topics((next_token.empty? ? {} : { next_token: next_token }))
|
82
|
-
results.concat(resp.topics.map(&:topic_arn))
|
83
|
-
next_token = (resp.next_token.empty? ? '' : resp.next_token)
|
84
|
-
break if next_token.empty?
|
85
|
-
end
|
86
|
-
results
|
87
|
-
end
|
88
|
-
|
89
|
-
# Send a message to a Channel using SNS#publish
|
90
|
-
#
|
91
|
-
# Parameters
|
92
|
-
# * opts +Hash+ - this includes all the keys AWS uses but for now it only has defaults
|
93
|
-
# for topic_arn and the message
|
94
|
-
# * * +:topic_arn+ - the ARN for the topic in AWS
|
95
|
-
# * * +:message+ - the message that should be broadcasted to whoever is listening on this
|
96
|
-
# Channel (AWS Topic)
|
97
|
-
def send_broadcast(opts = {})
|
98
|
-
msg = opts.delete(:message) || ""
|
99
|
-
|
100
|
-
package = {
|
101
|
-
topic_arn: "topicARN",
|
102
|
-
message: msg.to_json
|
103
|
-
}.merge(opts)
|
104
|
-
|
105
|
-
sns.publish(package)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|