dmarro89 / dare-db

Dare-DB is a lightweight in-memory database written in Go, featuring Redis-inspired hashtables and HTTP/HTTPS endpoints for seamless data storage and retrieval, with Docker support for easy deployment
MIT License
16 stars 1 forks source link

i tried it... #21

Closed go-while closed 2 weeks ago

go-while commented 2 weeks ago

... and failed

your main.go looks wrong and did not work out of the box.

you're not passing the mux to http.ListenAndServe, there is nil instead of the mux?

all requests (get/set/delete) via curl just failed with error: 404 page not found

this fixed it

    err := http.ListenAndServe(fmt.Sprintf(":%d", port), mux)

happy coding

go-while commented 2 weeks ago

another bug?


    mux.HandleFunc("GET /get/{key}/", srv.HandlerGet)
    mux.HandleFunc("POST /set", srv.HandlerSet)
    mux.HandleFunc("DELETE /delete/{key}/", srv.HandlerDelete)

you have / at the end but in server_test and in all requests they are missing, so they should be removed here ;)

go-while commented 2 weeks ago

another question i can't figure out yet is the use of GetRandomBytes which as far as i can tell not even initialized? the init() func exists but is not called anywhere.

i moved the datastr into database and added some mutexes.

just playing around and maybe prepare some heavy load tests.

but still to many questions with some parts of the code. i'm sure i can remove 90% of this very complicated looking parts, the rehashing and indexes and it works better :dancers:

you have this in active use or just for fun?

https://github.com/go-while/dare-db/tree/playground

go-while commented 2 weeks ago

D'oh! looks like the main branch is not up to date figured out you're working in 19-deployment-with-docker-and-https ...

dmarro89 commented 2 weeks ago

Hi @go-while, thanks for your comments. I'll check for what you're writing. Anyway it's a WIP, @vdmitriyev has added some code that should be optimized in other PRs. What you're saying about the GetRandomBytes is related to this other project. I'll prefer to talk about it in the apposite issues section. Anyway the init method is called from golang only once and when the application starts -> https://tutorialedge.net/golang/the-go-init-function/. So there's no need to call it.

The project is just for fun, maybe in the future it could become something of useful or maybe not but it's not important. Thanks for you contribution, feel free to open some PRs if you want. I'll take a look to your code. I have just added some optimization to the hashing part and some benchmarking to understand how cpu and mem usage can be improved.

Thanks again for your contribution.

dmarro89 commented 2 weeks ago

Hi @go-while thanks again for your contribution. Could you please update your fork with the main branch ?

vdmitriyev commented 2 weeks ago

Despite being a for fun project, I am really looking forward to use it as a component in one of an internal projects 🤞

go-while commented 2 weeks ago

i'll try merge my changes but at the moment it just fails... modules and gopath are fu.... around with mee ! head -> wall!

go-while commented 2 weeks ago

lets stay in discussions, is not an issue here