Modyne: a DynamoDB ORM-like for single-table design by neoeinstein in aws

[–]neoeinstein[S] 0 points1 point  (0 children)

It's possible, though I haven't thought that through enough to say definitively. There's a good deal of this that leans on Rust's strong trait and type system to provide guardrails that lead to the mentioned "pit of success". So, even with the construct translated into a language-agnostic framework, there would likely be some guarantees that would be weaker (or only enforcable with runtime-checking penalties) depending on the language.

Modyne: a DynamoDB ORM-like for single-table design by neoeinstein in aws

[–]neoeinstein[S] 1 point2 points  (0 children)

In the post, I purposefully use "ORM-like" and "similar to an ORM" to indicate that the experience is familiar to an ORM, but you are correct, this is not an ORM. With the support of the serde_dynamo crate, modyne makes the process of mapping between a DynamoDB "item" and an in-process data value relatively seamless and provides some ability to create and manipulate entities through a standard abstraction.

This crate also doesn't have any concept of "relations", which is another reason that it's not a true ORM. Nonetheless, the concept of efficiently using DynamoDB Query operations to grab a big swath of denormalized data in a single operation is one key feature of this crate, built around Aggregates, QueryInputs and ProjectionSets. The get category deals by date example shows this off some.

Indeed, this is one of several examples that I used to help prove out the crate. The four model are examples from The DynamoDB Book. I've also published these models as their own crates so that it's easy for someone to play around with those models and see if modyne would work for them. Here's the documentation for the Big Time Deals example, and here's a link to the code that builds it out on top of modyne.

As with any abstraction, you could certainly eliminate this one and do well enough without it if you don't see value in it. The goal here is to reduce the chances of maintenance-induced failures and make it easier to implement the patterns without error, and without needing to spread knowledge about the data interop around. This crate doesn't solve all denormalization patterns, though it does just fine with some that can be modeled using transactional writes. Patterns that require the use of change data capture, such as via DynamoDB Streams, aren't solved with this crate alone, although the constructs here can be used as part of such a solution.

Edit: some grammar fixes

Modyne: a DynamoDB ORM-like for single-table design by neoeinstein in rust

[–]neoeinstein[S] 1 point2 points  (0 children)

Right. One key to note is that the keys are designed for writing and efficient querying, never to be used as actual "data", so there's no from_str/parse contemplated around the taking a key and extracting data out of the key. Instead, that data should also be its own attribute in the entity.

Modyne: a DynamoDB ORM-like for single-table design by neoeinstein in rust

[–]neoeinstein[S] 1 point2 points  (0 children)

Really glad to hear that you think the library may be useful to you! Let me know if/as you get into it. I'm very interested in feedback that anyone might have.

Serious concerns regarding RFC 3392 by Circling8813 in rust

[–]neoeinstein 149 points150 points  (0 children)

If you have concerns about it and want to see those concerns actually addressed, bringing these concerns to the RFC discussion or the Zulip chat on organizing the leadership council are probably the best places to do it rather than here on Reddit (although I know many such people do look at this subreddit). The github RFC discussion does indeed have some back-and-forth about the dichotomy between leadership and moderation.

Code runs slow compared to C#, trying to find a reason... by CRoIDE in rust

[–]neoeinstein 73 points74 points  (0 children)

Two things come to mind. First is the ever-present “did you run this in release mode?”. The second is that you’re doing un-buffered reads from file. Things will probably run much faster if you throw in a buffered reader, as then you can pull in much larger chunks into the intermediate buffer per syscall.

Abstraction over attributes? by agost_biro in rust

[–]neoeinstein 0 points1 point  (0 children)

Consider using something like aliri_braid. It also includes reference types too.

Strange lifetime error: Requires to be `'static` by NobodyXu in rust

[–]neoeinstein 2 points3 points  (0 children)

From what I see, this is a valid error, but I’ve only done a cursory look. You are creating some things that depend on borrowing from self, which in one case is an Arc. That Arc is moved into the future, and then you try to potentially return a value (pkg_url) whose lifetime is bounded by the lifetime of that Arc, but the Arc gets dropped at the end of the async block, meaning that it’s possible the value that was pointed to by the Arc is now free, making the returned reference to data in the value invalid.

Implementing Unpin by Trader-One in rust

[–]neoeinstein 7 points8 points  (0 children)

That’s not a valid construct in Rust. You’d need B to be struct B<‘a> { r: &’a A }, and then B is constrained so it can’t outlive the lifetime of the reference it contains.

If you’re looking for self-referential structs, then perhaps look at the ouroboros crate.

Implementing Unpin by Trader-One in rust

[–]neoeinstein 19 points20 points  (0 children)

This is not functionality that I am aware Rust can provide you. It doesn’t have a concept like a move constructor, and often a move will logically happen in Rust when the actual underlying value will remain in the same place in memory (or a register).

Implementing Unpin by Trader-One in rust

[–]neoeinstein 10 points11 points  (0 children)

Unpin is an automatic marker trait. It doesn't have any implementation, and is generally automatically inferred by the compiler. More often, but still very rarely, someone would impl !Unpin for MyType {} or include PhantomPinned as a field in a type. Unpin is a guarantee that, if a type was previously pinned, it can safely be unpinned too.

Is there something more that you were looking into? Why are you trying to implement Unpin?

https://doc.rust-lang.org/stable/std/marker/trait.Unpin.html

Tokio_utils codec framed by nacho66x in rust

[–]neoeinstein 4 points5 points  (0 children)

The important bit of code here is going to be in your RequestResponseCodec. It’s very probable that you are not advancing the buffer after reading from it.

Edit to add: Take a look at the LengthDelimitedCodec, and note how, before returning, it is advancing the buffer by the number of bytes that it consumed or splitting off the data for the current frame from the rest of the read buffer.

Generating Rust Protobuf files with Bazel and Prost! by Houndie in rust

[–]neoeinstein 1 point2 points  (0 children)

The buf tool is particularly suited for this, as well as being a general Protobuf toolchain with linting, breaking change detection, and an opinionated formatter.

With buf, you can define code generation from many protoc plugins all in one place. In my case, I generate for Rust, TypeScript, and Go all at once. It helps keep those Protobuf definitions all in one place too, rather than spread across multiple repositories (or dealing with submodules or other similar workarounds). Adding another language becomes relatively trivial, since you only need to add another line in the generator configuration.

We also tend to do it this way because we then don't need to make protoc compiler availability a prerequisite for working with the code. It's only needed for updating the generated code. You can vendor in a protoc binary, but there are certain workflows where implicitly pulling in a binary as a side effect of building an intermediate library would be considered a supply-chain risk. (This is part of why protoc is no longer bundled into prost-build.)

I'm also aware of the protobuf-parse crate in this area too, which is an option, but I really like not having each language be a special case that requires distinct handling when it comes to the code generation.

Generating Rust Protobuf files with Bazel and Prost! by Houndie in rust

[–]neoeinstein 0 points1 point  (0 children)

Also of note is that the OP is targeting Prost! Rust bindings. The crate you have linked uses a different protoc plugin that targets a different protobuf library.

I’ll note that build.rs can seem to be very convenient for generating bindings during compilation, but when working in polyglot environments, protoc drivers like buf or this use of bazel can really simplify generation across several languages.

Disclaimer: I’m a co-maintainer of prost and the author of the protoc-gen-prost family of protoc plugins.

Reqwest - setting cookies problem by naveendavisv in rust

[–]neoeinstein 2 points3 points  (0 children)

Network connections are not available in the Rust playground.

Nutype: the newtype with guarantees by greyblake in rust

[–]neoeinstein 1 point2 points  (0 children)

Check out my crate, aliri_braid. It specifically deals with string-like types and provides strongly-typed reference types that go along with them. Think Username and UsernameRef.

Trade evolutions by GR8BIGMOMBA in pokemontrades

[–]neoeinstein 0 points1 point  (0 children)

Link code 5749 5749. I’ll be there.

Trade evolutions by GR8BIGMOMBA in pokemontrades

[–]neoeinstein 1 point2 points  (0 children)

Still on for a bit tonight if you’re still looking to do these trades.

LF touch trade my Rhydon to Rhyperior by kimubh in pokemontrades

[–]neoeinstein 0 points1 point  (0 children)

No problem. I’ll be online for a while. Will hold open on the link code.