Skip to content

Commit 497417a

Browse files
Merge pull request #35 from invenia/MB/AWS.jl
Converted to use AWS.jl
2 parents b47c2ca + 481bc70 commit 497417a

File tree

7 files changed

+116
-185
lines changed

7 files changed

+116
-185
lines changed

.github/workflows/CI.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
version:
18-
- "1.0" # LTS
18+
- "1.3" # Minimal version of the package
1919
- "1" # Latest Version
2020
os:
2121
- ubuntu-latest
@@ -31,9 +31,9 @@ jobs:
3131
- os: windows-latest
3232
arch: x86
3333
include:
34-
# Add a 1.5 job because that's what Invenia actually uses
34+
# Add a 1.6 job because that's what Invenia actually uses
3535
- os: ubuntu-latest
36-
version: 1.5
36+
version: 1.6
3737
arch: x64
3838
steps:
3939
- uses: actions/checkout@v2

Project.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name = "CloudWatchLogs"
22
uuid = "c4c1e6a2-6bdd-52e0-b56d-1d4734724d2d"
3-
version = "1.2.1"
3+
version = "2.0.0"
44

55
[deps]
6-
AWSCore = "4f1ea46c-232b-54a6-9b17-cc2d0f3e6598"
6+
AWS = "fbe9abb3-538b-5e4e-ba9e-bc94f4f92ebc"
77
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
88
MbedTLS = "739be429-bea8-5141-9913-cc70e7f3736d"
99
Memento = "f28f55f0-a522-5efc-85c2-fe41dfb9b2d9"
@@ -12,12 +12,12 @@ TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53"
1212
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
1313

1414
[compat]
15-
AWSCore = "0.6"
16-
MbedTLS = "0.5, 0.6, 0.7, 1"
17-
Memento = "0.13, 1"
15+
AWS = "1"
16+
MbedTLS = "1"
17+
Memento = "1"
1818
Mocking = "0.7"
19-
TimeZones = "0.9, 0.10, 0.11, 1"
20-
julia = "1"
19+
TimeZones = "1"
20+
julia = "1.3" # Minimum version for MbedTLS@1
2121

2222
[extras]
2323
EzXML = "8f5d6c58-4d21-5cfd-889c-e3ad7ee6a615"

src/CloudWatchLogs.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
__precompile__()
22
module CloudWatchLogs
33

4-
using AWSCore: AWSConfig, AWSException
5-
using AWSCore.Services: logs
4+
using AWS
5+
using AWS: AWSException
66
using Dates
77
using MbedTLS: MbedException
88
using Memento
99
using Mocking
1010
using TimeZones
1111
using UUIDs
1212

13+
@service CloudWatch_Logs
14+
1315
export CloudWatchLogStream, LogEvent, submit_log, submit_logs
14-
export create_group, delete_group, create_stream, delete_stream
16+
export create_group, delete_group, create_stream, delete_stream, describe_log_streams
1517
export CloudWatchLogHandler
1618
export StreamNotFoundException, LogSubmissionException
1719

src/stream.jl

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ function create_group(
6565
)
6666
if isempty(tags)
6767
aws_retry() do
68-
logs(config, "CreateLogGroup"; logGroupName=log_group_name)
68+
CloudWatch_Logs.create_log_group(log_group_name; aws_config=config)
6969
end
7070
else
7171
tags = Dict{String, String}(tags)
7272
aws_retry() do
73-
logs(config, "CreateLogGroup"; logGroupName=log_group_name, tags=tags)
73+
CloudWatch_Logs.create_log_group(log_group_name, Dict("tags"=>tags); aws_config=config)
7474
end
7575
end
7676
return String(log_group_name)
@@ -86,7 +86,7 @@ function delete_group(
8686
log_group_name::AbstractString,
8787
)
8888
aws_retry() do
89-
logs(config, "DeleteLogGroup"; logGroupName=log_group_name)
89+
CloudWatch_Logs.delete_log_group(log_group_name; aws_config=config)
9090
end
9191
return nothing
9292
end
@@ -107,12 +107,7 @@ function create_stream(
107107
log_stream_name::AbstractString="julia-$(uuid4())",
108108
)
109109
aws_retry() do
110-
logs(
111-
config,
112-
"CreateLogStream";
113-
logGroupName=log_group_name,
114-
logStreamName=log_stream_name,
115-
)
110+
CloudWatch_Logs.create_log_stream(log_group_name, log_stream_name; aws_config=config)
116111
end
117112
return String(log_stream_name)
118113
end
@@ -128,12 +123,7 @@ function delete_stream(
128123
log_stream_name::AbstractString,
129124
)
130125
aws_retry() do
131-
logs(
132-
config,
133-
"DeleteLogStream";
134-
logGroupName=log_group_name,
135-
logStreamName=log_stream_name,
136-
)
126+
CloudWatch_Logs.delete_log_stream(log_group_name, log_stream_name; aws_config=config)
137127
end
138128
return nothing
139129
end
@@ -149,7 +139,7 @@ function new_sequence_token(stream::CloudWatchLogStream)
149139
return new_sequence_token(stream.config, stream.log_group_name, stream.log_stream_name)
150140
end
151141

152-
describe_log_streams(config; kwargs...) = logs(config, "DescribeLogStreams"; kwargs...)
142+
describe_log_streams(config::AWSConfig, log_group_name::AbstractString, params::AbstractDict) = CloudWatch_Logs.describe_log_streams(log_group_name, params; aws_config=config)
153143

154144
"""
155145
new_sequence_token(stream::CloudWatchLogStream) -> Union{String, Nothing}
@@ -167,11 +157,13 @@ function new_sequence_token(
167157
)::Union{String, Nothing}
168158
response = aws_retry() do
169159
@mock describe_log_streams(
170-
config;
171-
logGroupName=log_group,
172-
logStreamNamePrefix=log_stream,
173-
orderBy="LogStreamName", # orderBy and limit will ensure we get just the one
174-
limit=1, # matching result
160+
config,
161+
log_group,
162+
Dict(
163+
"logStreamNamePrefix" => log_stream,
164+
"orderBy" => "LogStreamName", # orderBy and limit will ensure we get just the one
165+
"limit" => 1, # matching result
166+
),
175167
)
176168
end
177169

@@ -211,13 +203,12 @@ function update_sequence_token!(
211203
end
212204

213205
function _put_log_events(stream::CloudWatchLogStream, events::AbstractVector{LogEvent})
214-
logs(
215-
stream.config,
216-
"PutLogEvents";
217-
logEvents=events,
218-
logGroupName=stream.log_group_name,
219-
logStreamName=stream.log_stream_name,
220-
sequenceToken=sequence_token(stream),
206+
CloudWatch_Logs.put_log_events(
207+
events,
208+
stream.log_group_name,
209+
stream.log_stream_name,
210+
Dict("sequenceToken" => sequence_token(stream));
211+
aws_config=stream.config
221212
)
222213
end
223214

@@ -296,7 +287,7 @@ function submit_logs(stream::CloudWatchLogStream, events::AbstractVector{LogEven
296287
end
297288

298289
f = retry(delays=PUTLOGEVENTS_DELAYS, check=retry_cond) do
299-
@mock _put_log_events(stream, events)
290+
@mock CloudWatchLogs._put_log_events(stream, events)
300291
end
301292

302293
min_valid_event = 1

test/mocked_aws.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
CFG = AWSConfig()
66

77
function dls_patch(output)
8-
@patch function CloudWatchLogs.describe_log_streams(config; kwargs...)
8+
@patch function CloudWatchLogs.describe_log_streams(config, log_group_name, params)
99
output
1010
end
1111
end

0 commit comments

Comments
 (0)