Skip to content

Commit d3f2edc

Browse files
committed
more type fixes
1 parent 647f352 commit d3f2edc

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

lib/log_struct/integrations/shrine.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ def self.setup(config)
4545
Log::Shrine::Upload.new(
4646
storage: storage_sym,
4747
location: payload[:location],
48-
uploader: payload[:uploader],
48+
uploader: payload[:uploader]&.to_s,
4949
upload_options: payload[:upload_options],
5050
options: payload[:options],
51-
duration_ms: event.duration,
51+
duration_ms: event.duration.to_f,
5252
additional_data: payload.except(:storage, :location, :uploader, :upload_options, :options)
5353
)
5454
when Event::Download

lib/log_struct/log/shrine/metadata.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Metadata < T::Struct
3636

3737
# Event-specific fields
3838
const :storage, Symbol
39-
const :location, String
39+
const :location, T.nilable(String), default: nil
4040
const :metadata, T.nilable(T::Hash[String, T.untyped]), default: nil
4141

4242
# Additional data
@@ -63,13 +63,13 @@ def self.base_hash
6363
timestamp: T.untyped).returns(T::Hash[LogStruct::LogField, T.untyped])
6464
}
6565
def self.build(storage:,
66-
location:,
66+
location: nil,
6767
metadata: nil,
6868
additional_data: nil,
6969
timestamp: Time.now)
7070
h = base_hash
7171
h[LogField::Storage] = storage
72-
h[LogField::Location] = location
72+
h[LogField::Location] = location unless location.nil?
7373
h[LogField::Metadata] = metadata unless metadata.nil?
7474
h
7575
end

schemas/log_sources/shrine.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ events:
3939
Metadata:
4040
fields:
4141
Storage: Symbol
42-
Location: String
42+
Location:
43+
type: String
44+
required: false
4345
Metadata:
4446
type: 'T::Hash[String, T.untyped]'
4547
required: false

0 commit comments

Comments
 (0)