lib/schema.rb in streamdal-0.0.1 vs lib/schema.rb in streamdal-0.0.2

- old
+ new

@@ -1,38 +1,32 @@ +# frozen_string_literal: true + include Streamdal::Protos module Schemas def _set_schema(aud, schema) s = Streamdal::Protos::Schema.new s.json_schema = schema @schemas[aud_to_str(aud)] = s end def _get_schema(aud) - if @schemas.key?(aud_to_str(aud)) - return @schemas[aud_to_str(aud)].json_schema - end + return @schemas[aud_to_str(aud)].json_schema if @schemas.key?(aud_to_str(aud)) - "" + '' end def _handle_schema(aud, step, wasm_resp) # Only handle schema steps - if step.infer_schema.nil? - return nil - end + return nil if step.infer_schema.nil? # Only successful schema inferences - if wasm_resp.exit_code != :WASM_EXIT_CODE_TRUE - return nil - end + return nil if wasm_resp.exit_code != :WASM_EXIT_CODE_TRUE # If existing schema matches, do nothing existing_schema = _get_schema(aud) - if existing_schema == wasm_resp.output_step - return nil - end + return nil if existing_schema == wasm_resp.output_step _set_schema(aud, wasm_resp.output_step) req = Streamdal::Protos::SendSchemaRequest.new req.audience = aud @@ -42,6 +36,6 @@ # Run in thread so we don't block on gRPC call Thread.new do @stub.send_schema(req, metadata: _metadata) end end -end \ No newline at end of file +end