Skip to content

RFC: Backend models

Jacob Michalskie edited this page Mar 18, 2024 · 3 revisions

Approved by:

Reality?

OBS uses multiple ways to parse XML it receives from the backend

We have multiple parsing abstractions like:

  • ActiveModel (ex. LocalBuildResult, Patchinfo)
  • Xmlhash objects (ex. Directory, many Controllers)
  • Nokogiri objects (API controllers)
  • REXML objects (API controllers)

This happens everywhere within the code base.

Consequences?

  • We have to context switch with every single instance of a backend response we encounter
  • It's not clear which solution is the preferred one for new code
  • Results from the Xmlhash, Nokogiri and REXML approaches behave like a low level Hash object that contains other low level data types (String, Hash, Array). This often leads to more "low level"/complex code to manipulate/transform the hash and it's content.

Future?

  • There is one preferred way to parse the backend responses, with an adequate backend library that gives us a parsed response directly
  • We can specify the structure of the XML declaratively, and directly use it to parse the responses

Proposal!

Code wise, this is the POC: https://github.com/openSUSE/open-build-service/compare/master...hellcp-work:open-build-service:backend-models-poc. Besides introducing the gem and the structure, the aim of it was to present an initial, more readable replacement for https://github.com/openSUSE/open-build-service/blob/master/src/api/app/models/local_build_result/for_package.rb

Introducing this more widely into the code base would require:

  • Implementing new Backend::Xml responses
  • Implementing required Backend models
  • Replacing existing backend call + parser with Backend model methods
  • Whenever we still need string output, we keep using Backend::Api

Related proposal

https://etherpad.opensuse.org/p/obs-backend-models-rendering

Clone this wiki locally