Class: Svix::StreamSinkIn
- Inherits:
-
Object
- Object
- Svix::StreamSinkIn
- Defined in:
- lib/svix/models/stream_sink_in.rb
Instance Attribute Summary collapse
-
#batch_size ⇒ Object
How many events will be batched in a request to the Sink.
-
#config ⇒ Object
Returns the value of attribute config.
-
#event_types ⇒ Object
A list of event types that filter which events are dispatched to the Sink.
-
#max_wait_secs ⇒ Object
How long to wait before a batch of events is sent, if the ‘batchSize` is not reached.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#status ⇒ Object
Whether the sink will receive events.
-
#uid ⇒ Object
An optional unique identifier for the sink.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ StreamSinkIn
constructor
A new instance of StreamSinkIn.
- #serialize ⇒ Object
-
#to_json ⇒ Object
Serializes the object to a json string.
Constructor Details
#initialize(attributes = {}) ⇒ StreamSinkIn
Returns a new instance of StreamSinkIn.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/svix/models/stream_sink_in.rb', line 127 def initialize(attributes = {}) unless attributes.is_a?(Hash) fail( ArgumentError, "The input argument (attributes) must be a hash in `Svix::StreamSinkIn` new method" ) end attributes.each do |k, v| unless ALL_FIELD.include?(k.to_s) fail(ArgumentError, "The field #{k} is not part of Svix::StreamSinkIn") end if k == "config" unless TYPE_TO_NAME.key?(v.class) fail(ArgumentError, "The field #{k} can't be a `#{v.class}` expected one of #{TYPE_TO_NAME.keys}") end instance_variable_set("@__enum_discriminator", TYPE_TO_NAME[v.class]) end instance_variable_set("@#{k}", v) instance_variable_set("@__#{k}_is_defined", true) end if @__enum_discriminator.nil? fail(ArgumentError, "Required config field was not set") end end |
Instance Attribute Details
#batch_size ⇒ Object
How many events will be batched in a request to the Sink.
84 85 86 |
# File 'lib/svix/models/stream_sink_in.rb', line 84 def batch_size @batch_size end |
#config ⇒ Object
Returns the value of attribute config.
102 103 104 |
# File 'lib/svix/models/stream_sink_in.rb', line 102 def config @config end |
#event_types ⇒ Object
A list of event types that filter which events are dispatched to the Sink. An empty list (or null) will not filter out any events.
86 87 88 |
# File 'lib/svix/models/stream_sink_in.rb', line 86 def event_types @event_types end |
#max_wait_secs ⇒ Object
How long to wait before a batch of events is sent, if the ‘batchSize` is not reached.
For example, with a ‘batchSize` of 100 and `maxWaitSecs` of 10, we will send a request after 10 seconds or 100 events, whichever comes first.
Note that we will never send an empty batch of events to the Sink.
92 93 94 |
# File 'lib/svix/models/stream_sink_in.rb', line 92 def max_wait_secs @max_wait_secs end |
#metadata ⇒ Object
Returns the value of attribute metadata.
93 94 95 |
# File 'lib/svix/models/stream_sink_in.rb', line 93 def @metadata end |
#status ⇒ Object
Whether the sink will receive events.
If the sink is ‘enabled`, any events posted to the stream will be dispatched to the Sink in the same order that events were posted to the stream.
If the sink is ‘disabled`, events will not be dispatched to the sink until the sink is reenabled.
99 100 101 |
# File 'lib/svix/models/stream_sink_in.rb', line 99 def status @status end |
#uid ⇒ Object
An optional unique identifier for the sink.
101 102 103 |
# File 'lib/svix/models/stream_sink_in.rb', line 101 def uid @uid end |
Class Method Details
.deserialize(attributes = {}) ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/svix/models/stream_sink_in.rb', line 157 def self.deserialize(attributes = {}) attributes = attributes.transform_keys(&:to_s) attrs = Hash.new attrs["batch_size"] = attributes["batchSize"] attrs["event_types"] = attributes["eventTypes"] attrs["max_wait_secs"] = attributes["maxWaitSecs"] attrs["metadata"] = attributes["metadata"] attrs["status"] = Svix::SinkStatusIn.deserialize(attributes["status"]) if attributes["status"] attrs["uid"] = attributes["uid"] unless NAME_TO_TYPE.key?(attributes["type"]) fail(ArgumentError, "Invalid type `#{attributes["type"]}` expected on of #{NAME_TO_TYPE.keys}") end unless attributes.key?("config") fail(ArgumentError, "Missing required field config") end attrs["config"] = NAME_TO_TYPE[attributes["type"]].deserialize(attributes["config"]) new(attrs) end |
Instance Method Details
#serialize ⇒ Object
178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/svix/models/stream_sink_in.rb', line 178 def serialize out = Hash.new out["batchSize"] = Svix::serialize_primitive(@batch_size) if @batch_size out["eventTypes"] = Svix::serialize_primitive(@event_types) if @event_types out["maxWaitSecs"] = Svix::serialize_primitive(@max_wait_secs) if @max_wait_secs out["metadata"] = Svix::serialize_primitive(@metadata) if @metadata out["status"] = Svix::serialize_schema_ref(@status) if @status out["uid"] = Svix::serialize_primitive(@uid) if @uid out["type"] = @__enum_discriminator out["config"] = @config.serialize out end |
#to_json ⇒ Object
Serializes the object to a json string
193 194 195 |
# File 'lib/svix/models/stream_sink_in.rb', line 193 def to_json JSON.dump(serialize) end |