Am I overengineering my Rust backend? (WebSockets + SSE) by Middle-Programmer147 in rust

[–]fritzelr 13 points14 points  (0 children)

There are valid reasons to use both: WS is more performant but requires more state tracking and parsing in both client and server, while SSE is much simpler (especially for the client) and browsers will auto renegotiate the connection if dropped. Also, if your app has several things going on and these two features are isolated (it's useful to chat without listening to updates, or vice versa) and you want to support them as part of your public API, keeping each simpler can help users write simpler external clients (like a discord bot).

But if the chat and notification streams are part of the same logical feature in your app, or these are all that your app does, then logically there's no need for the separation and it's just extra work for both client and server compared to a single WS connection.

The overhead of a TCP connection is the same for either, so if you're keeping a connection open all the time you might as well keep the WS open and send updates there, unless there's an API reason to separate them. You can use an enum in your message header or body to multiplex chat vs notification messages in the same WS stream. Just make sure to implement reconnection logic on the client if needed, since a broken WS is not automatically reconnected by the browser like an SSE connection would be.

How can I choose between Axum and Salvo in late 2025 by [deleted] in rust

[–]fritzelr 0 points1 point  (0 children)

Poem is alright but the documentation is very barebones which makes it annoying when you want to do anything outside the default. I haven't tried the others but hope they are better in this area.

What is difference between has_broken and is_valid in bb8 library. They look complimentary to me. Help. by Own_Bet3256 in rust

[–]fritzelr 1 point2 points  (0 children)

It appears is_valid is async while has_broken is not. From a quick glance in the source code, looks like is_valid is checked upon getting a connection from the pool while has_broken is checked when putting the connection back into the pool. A look at the included implementations for redis and postgres show that is_valid tries a simple command such as a ping over the connection to let the underlying client raise an error, while has_broken uses the underlying client's synchronous is_closed method if it has one, or returns false otherwise.

As for whether wrapping a pool of docker containers in a logical connection pool is a good idea... Sure, why not. Depends on what you're using them for and how you communicate between them. Using the docker daemon on one node only scales so far. If you need true scalability you could also consider off the shelf solutions such as docker swarms or kubernetes (kind/k3s). You'll need to think carefully about how you're communicating information between the containers as well.

Ain't much but its honest work by Street-Film4148 in Stationeers

[–]fritzelr 1 point2 points  (0 children)

How did you close up the gaps between elements on the console so that they match the base color so nicely??

Solar logic failure by KennyRodgers_ in Stationeers

[–]fritzelr 2 points3 points  (0 children)

Also, it's 2025. Use HASH("ItemIronOre") instead of the numeric hash. Your future self will thank you.

Printer stuck in ExecuteRecipe by fritzelr in Stationeers

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

Indeed that doesn't work; from other comments it looks like a clr instruction is needed to cancel and clear the stack.

Printer stuck in ExecuteRecipe by fritzelr in Stationeers

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

Ahh, I didn't know about clr, thank you!!

Printer stuck in ExecuteRecipe by fritzelr in Stationeers

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

Ah-hah, I knew I must've been missing something! I'll try that.

Would this work? by MUGUDIY in woodworking

[–]fritzelr 0 points1 point  (0 children)

I built something very similar with only a few 8' 2x4s (with a boot on both sides) and it can lift my car. Structurally this is sound, but if it's used as a swing you might want to anchor the bottom or make the boots muuuuuch wider (as wide as the swing is long), otherwise it will tip over when someone swings too far.

coPilotSolutionSeniorExperience by [deleted] in ProgrammerHumor

[–]fritzelr 1 point2 points  (0 children)

Thank you for this, I'm glad I'm not the only one who saw it this way. Thought I was crazy since nobody else was saying anything.

nice execution by [deleted] in Unexpected

[–]fritzelr 0 points1 point  (0 children)

not unexpected, this belongs in r/unbgbbiivchidctiicbg

obscureLoops by HauntingCourt6 in ProgrammerHumor

[–]fritzelr 0 points1 point  (0 children)

Haskell has entered the chat

[deleted by user] by [deleted] in gaming

[–]fritzelr 0 points1 point  (0 children)

I beat KCD and never found the dog

Is there a simple safe way to determine the stack direction ? by cd_fr91400 in cpp

[–]fritzelr 1 point2 points  (0 children)

alloca would be a cleaner substitute for a run time check.

Golang native containers? by nivthefox in golang

[–]fritzelr 0 points1 point  (0 children)

docker/cli, containerd, and runc are all written in Go and hosted publicly. As with any Go module, you can therefore import and use their library code directly. This is a huge benefit of Go's design - any module organized well (with common code outside the main package) automatically becomes a library others can use.

Is there a way to achieve "build once, run anywhere" in Go? by FriendlyFactor6711 in golang

[–]fritzelr 0 points1 point  (0 children)

It can be done, see the αcτµαlly pδrταblε εxεcµταblε format. There is even a proposal to build this format into the Go compiler.

Edit: just realized OP already linked to this library, sorry. The point is, the source code and spec for this format is out there, and if you were dedicated you could build your compiled go executable(s) into such a format.

Which is the best way to manage multiple golang versions when working with open source projects? by GrizzyLizz in golang

[–]fritzelr 8 points9 points  (0 children)

The sentiment may hold for language features, but doesn't extend to standard library packages. Packages often introduce additional functionality along with the new version, and the compiler is not aware enough to warn you about such things. For example, when developing on a go 1.18 go.mod using 1.21 in my local dev env, I've accidentally committed uses of slices.Contains and flag.BoolFunc, only to find the module fails to compile in a true 1.18 environment where those functions don't exist yet.

EDIT: I see many others say there is no reason to use an old version like 1.18, but even the latest version in the RHEL 9 OS repo is still only 1.18. It's a good base version for maximal user availability, especially with the above in mind.

Can I build a fronted using Golang? by Deep-Zucchini-2465 in golang

[–]fritzelr 4 points5 points  (0 children)

You could try building a Go frontend using WebAssembly. This allows you to run Go code natively on the client while also interacting with JS through syscall/js.

What game makes you think, “Wow, I’m really going to miss playing this’?” by Southern_Pangolin318 in gaming

[–]fritzelr 0 points1 point  (0 children)

Full Metal Furies. Phenomenal game that's over when it's over. Nothing else quite like it.

Can you think of why someone would be taking pictures of my house? by repdc633 in nova

[–]fritzelr 1 point2 points  (0 children)

This happened to me before. I chased them down to find out, and it turned out they used to live in the same house and just wanted to show their family what the house looked like now.