9 comments

  • banashark a day ago ago

    How does this work internally?

    From the docs, it looks like it's building a graph to retrieve data, though the comparison it gives contrasts it to doing many small individual queries and passing them to other methods to get evaluated.

    I find in the apps I'm working on, either services will build complex queries themselves, or they need to make multiple queries due to data needing transformations between queries that aren't simple to facilitate in the database itself (these services also tend to avoid code in the database, which I'm mixed on).

    In the "Deep Composition" section it has a comment in the code `// These three tiles run in parallel`. Does that mean that the way of composition is through pulling in multiple different pieces of data then joining at the application layer?

    I'm coming from a very much sql mindset and trying to understand the intended mechanism for data retrieval here. It kind of reminds me of how ad-hoc LINQ queries use Expression trees to resolve sql queries, but not exactly the same.

    Or is the thought more that this would be used when you have many disparate data stores (micro services, databases, caches, etc) and doesn't make sense for a monolithic single-database application)?

    • Nick-Abbott a day ago ago

      I think the disconnect we’re having here is what you’re looking for in a framework. Mosaic doesn’t help you accept incoming traffic or make your upstream requests, it just helps manage your business logic in between.

      For an application with just one upstream data source, you’re right it probably doesn’t make sense to use this framework. My background is in fintech where we deal with dozens of data sources at the same time in large orchestration APIs and that’s where this system shines. It allows you to run all of these upstream requests in parallel without writing any coroutine boilerplate and access their results anywhere in your logic without needing to pass around the various responses.

      As for how it works, it really isn’t doing anything too surprising. There is no actual graph being created, the behavior just acts like one exists. Mosaic inserts stubs into short-lived caches which causes tiles to wait on eachother at runtime. Once the tile is completed, the stub receives the result and all the waiting tiles get it too. It eagerly runs every piece of logic you give it while guaranteeing that it will never run twice for a request.

      • banashark a day ago ago

        Yeah that makes a lot more sense. I can see how this would be a nice direction to take things instead of trying to retrofit graphql or some other layer onto an existing architecture.

        • Nick-Abbott a day ago ago

          Yep! It’s perfect for microservices, orchestration APIs, BFF APIs, etc. It’s designed as a way to augment your favorite ORMs and HTTP clients rather than replace the whole stack.

  • FranzJosef 2 days ago ago

    Interesting! This framework tackles complex APIs with contract-first design and real integration testing - no mocking! Sounds like a strong solution for API sprawl, and the Apache 2.0 license is great. Performance and ease of learning are the key questions I'd have. Worth a look.

    • Nick-Abbott 2 days ago ago

      Any framework does add overhead, and this is no exception. But Mosaic does a pretty good job of keeping things flowing. All of your API requests are running on totally separate threads with no shared memory to get blocked. The overhead is limited to a native ConcurrentHashMap lookup per tile invocation and the map instance is unique per API request, even when multiple are being handled at the same time. Shouldn’t be a concern for 99% of use cases.

      As for the ease of learning, please, give it a try! I think it’s very straightforward but I’m obviously a bit biased. Would welcome good feedback to incorporate into a v1 release.

  • aerzen 2 days ago ago

    That's a nice abstraction, kudos. I wish I'd read this README before I started my backend project.

    Does anyone know of a similar package in rust? My kotlin is a bit lacking to understand everything here.

  • ImPleadThe5th 2 days ago ago

    Looks interesting!

    Can anyone remind me. There's some .Net library that works similarly right?

  • Rigoberto 2 days ago ago

    I want to know about this app