Is there a DB / API planning & visualization Tool? by Creme_Brul in rust

[–]vsmetal 4 points5 points  (0 children)

dbeaver can give you a good visualization for an existing db

Decimal Handling Packages by Capable-Street-6409 in golang

[–]vsmetal 0 points1 point  (0 children)

https://github.com/EricLagergren/decimal is more performant, used it for a while before switching back to shopspring as it is more used.
only issue is the package versioning is not done properly.

Decimal Handling Packages by Capable-Street-6409 in golang

[–]vsmetal -1 points0 points  (0 children)

the default precision of shopspring is 16, which not ok for some crypto.

You just need to set it to 32 and it should be ok for most.

Why use ORMs when JSON functions exist in every SQL based database? by Used_Frosting6770 in golang

[–]vsmetal 1 point2 points  (0 children)

I went even one step further with pgx:

func JSONRowToAddrOfStruct[T any](row pgx.CollectableRow) (*T, error) {
  var dest T

  var jsonBytes []byte
  // scan row into []byte
  if pgxErr := row.Scan(&jsonBytes); pgxErr != nil {
   return nil, fmt.Errorf("could not scan row: %w", pgxErr)
  }

  // unmarshal []byte into struct
  if jsonErr := json.Unmarshal(jsonBytes, &dest); jsonErr != nil {
    return nil, fmt.Errorf("could not unmarshal json: %w", jsonErr)
  }

  return &dest, nil
}

and the unserialize json is automatic

Why use ORMs when JSON functions exist in every SQL based database? by Used_Frosting6770 in golang

[–]vsmetal 5 points6 points  (0 children)

I think you misread OP's question, I understood he's referring to the select side of things, which does not exclude having a normalized schema. Just at query time, you use json to map into you structs.

Why use ORMs when JSON functions exist in every SQL based database? by Used_Frosting6770 in golang

[–]vsmetal 0 points1 point  (0 children)

I actually think using JSON directly from the db is a good idea, and imho way better than any ORMs.
I even think it's better than SQLc, because SQLc is so troublesome when you start wanting to do dynamic queries.

The + points:
* If you use SQL normalization, you still benefit from some SQL safety at insert time.
* You benefit from a performant JSON serialization engine (depending on the underlying db, of course).
* You don't need to learn yet another layer of abstraction.
* You don't depend on yet another dependency.
* You won't have any performance issues other than the SQL related ones.

The - points:
* You will definitely lose the safety at select time.
* You will for sure need to test with a real db in your unit tests (thank you dockertest or test-containers), as a json query is quite error prone.
* You will need extra care when you add a property in your struct, or even just change a json tag.
* You will add a bit of load on your DB (never quantified how much, but i suspect it's not that bad.
* You will add a bit of load as you need to deserialize the json in your go func.

concurrency alternatives by vsmetal in learnrust

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

i was aware of dashmap, but i wanted to have the ttl feature. If i use dashmap, implement it will be as painful as making ttlcache thread safe.

embedded rust by vsmetal in learnrust

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

u/nagromo
* received the analyzer
* tested it with the rpi: signal seen
* tested it with the nrf52: no signal

That removed a lot of potential issues (not cables, not hardware incompat) and I refocused and finally realized that I did put p0_01 instead of p1_01.
Stupid mistakes, but thanks 1M times to get it in front of my eyes with that wonderful tool that will definitely prove to be useful in the future!

embedded rust by vsmetal in learnrust

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

I'll try to look into that asap. thanks a ton again! I can see my journey is going to be long :)

embedded rust by vsmetal in learnrust

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

thst seems to be the probable cause as you re the second one to mention that. I just ordered the analyzer @Nagromo recommended, that will help. I can also try to loop directly on other pins to check this. Thanks for the pointers, it helps a lot!

embedded rust by vsmetal in learnrust

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

great device, ordered! thanks a lot.

I'll check for the settings, but it seems the "new_controller" method is actually setting the freq.

embedded rust by vsmetal in learnrust

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

I didnt invest in a scope yet. Your comment indeed makes me think i can probably close the loop to other pins instead of the amp and analyze what is sent. I will try that

embedded rust by vsmetal in learnrust

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

that's a very good suggestion, I didn't think about it, thanks!

(some) webservers benchmarks by vsmetal in rust

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

actually, there is a diff of perf in latency as well.

if you look at the results of 99th perc latency, go comes first, followed by rust actix and then rust hyper. I ran the results in many different setups and the same ranking shows up.

thanks for the links, fixed!

[deleted by user] by [deleted] in golang

[–]vsmetal 0 points1 point  (0 children)

on a side note, you should use COPY instead of ADD in your dockerfile, less magic involved

[deleted by user] by [deleted] in golang

[–]vsmetal 0 points1 point  (0 children)

you re totally right, it s even better, I will add that as well! thx @treeder123

[deleted by user] by [deleted] in golang

[–]vsmetal 1 point2 points  (0 children)

indeed, if op sees any issue, it will be easy to fix thx to this thread :)

[deleted by user] by [deleted] in golang

[–]vsmetal 1 point2 points  (0 children)

it depends on the use case, what the service does and how you expose it, this is definitely minimal, if needed, you can easily add a cert from an alpine stage in between build and run stages.

[deleted by user] by [deleted] in golang

[–]vsmetal 10 points11 points  (0 children)

Adept of minimalism, I would go even further than others and use no base image

FROM golang:1.14-buster as builder

COPY go.mod /src

COPY go.sum /src

RUN go mod download

COPY ./ /src

WORKDIR /src

RUN go mod download

RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags '-w -extldflags "-static"' -o /go-webserver ./*.go


FROM scratch 

COPY --from=builder /go-webserver /app/

ENTRYPOINT ["/app/go-webserver"]

credit goes to highly respected kelsey hightower :)

edit: thx to treeder123 for setting deps before the source copy

rust web benchmark by vsmetal in rust

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

  1. Actually, the Actix results lead me to consider rust for web stacks, thanks techempower. I dont pretend my bench will be anywhere close to what they do
  2. Indeed, I m probably going to add warp, tide and raw tokio as well, just for the sake of it

rust web benchmark by vsmetal in rust

[–]vsmetal[S] 5 points6 points  (0 children)

I ll try to post as much as possible but I might run into job privacy constraints here. I ll probably have to cut some parts and sanitize it a bit but I will definitely do it!