Class: SendmailLog

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/in_sendmail.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mta, time, record) ⇒ SendmailLog

Returns a new instance of SendmailLog.



121
122
123
124
125
126
127
128
# File 'lib/fluent/plugin/in_sendmail.rb', line 121

def initialize(mta, time, record)
  @mta = mta
  @status = :init
  @time = time
  @tos  = []
  @from = record
  @count = record["nrcpts"].to_i
end

Instance Attribute Details

#statusObject (readonly)

Returns the value of attribute status.



119
120
121
# File 'lib/fluent/plugin/in_sendmail.rb', line 119

def status
  @status
end

#timeObject (readonly)

Returns the value of attribute time.



120
121
122
# File 'lib/fluent/plugin/in_sendmail.rb', line 120

def time
  @time
end

Instance Method Details

#dequeued(time, record) ⇒ Object



152
153
154
155
156
157
158
# File 'lib/fluent/plugin/in_sendmail.rb', line 152

def dequeued(time, record)
  @count = @count - record["to"].size
  @tos.push(record)
  if @count == 0
    @status = :all_dequeued
  end
end

#recordObject



130
131
132
133
134
135
136
# File 'lib/fluent/plugin/in_sendmail.rb', line 130

def record
  return {
    "mta" => @mta,
    "from" => @from,
    "to" => @tos
  }
end

#record_unbundle(time, record) ⇒ Object



138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/fluent/plugin/in_sendmail.rb', line 138

def record_unbundle(time, record)
  records_unbundled = []
  for to in record["to"] do
    record_single = record.dup
    record_single["to"] = to
    records_unbundled.push({
      "mta" => @mta,
      "from" => @from,
      "to" => record_single
    })
  end
  return records_unbundled
end