module Aliyun::Log::Record::Persistence
Constants
- RESERVED_FIELDS
Public Instance Methods
dump_attributes()
click to toggle source
# File lib/aliyun/log/record/persistence.rb, line 150 def dump_attributes attributes.dup.tap do |tap| tap.each do |k, v| if self.class.attributes[k][:log_tag] || RESERVED_FIELDS.include?(k) tap.delete(k) else tap[k] = TypeCasting.dump_field(v, self.class.attributes[k]) end end end end
save(force = false)
click to toggle source
# File lib/aliyun/log/record/persistence.rb, line 162 def save(force = false) self.class.auto_load_schema run_callbacks(:create) do run_callbacks(:save) do force && validate! return false unless valid? saved = put_logs @new_record = false if saved saved end end end
save!()
click to toggle source
# File lib/aliyun/log/record/persistence.rb, line 175 def save! save(true) end
Private Instance Methods
generate_log()
click to toggle source
# File lib/aliyun/log/record/persistence.rb, line 200 def generate_log time = read_attribute(:__time__) || Time.now.to_i contents = dump_attributes.map { |k, v| { key: k, value: v.to_s } } Protobuf::Log.new(time: time, contents: contents) end
put_logs()
click to toggle source
# File lib/aliyun/log/record/persistence.rb, line 181 def put_logs log_tags = [] dump_log_tags.each do |k, v| log_tags << Protobuf::LogTag.new(key: k, value: v) end lg = Protobuf::LogGroup.new( logs: [generate_log], log_tags: log_tags, topic: read_attribute(:__topic__), source: read_attribute(:__source__) ) res = Log.record_connection.put_logs( self.class.project_name, self.class.logstore_name, lg ) res.code == 200 end