surrealdb / surrealdb.go

SurrealDB SDK for Golang
https://surrealdb.com
Apache License 2.0
232 stars 60 forks source link

Panic fix on gorilla ws when connection lost. #135

Open ElecTwix opened 4 months ago

ElecTwix commented 4 months ago

fix linter errors with shadow checking upgrade linter

ElecTwix commented 4 months ago

To be Noted: this PR changes how to create a connection it added a new step to call db.Initialize method to get ws start reading from db. this is needed because if something goes bad with the read it needs to return an error instead of panicking and crashing the program.

ElecTwix commented 3 months ago

Thanks! Looks good, but I am wondering about the need for a separate step. That step will always be immediately called after Connect. Is it possible to tie it together with that?

I tried that first but I'm not sure it is possible, we can add an error channel but I'm not sure that it will be easily understandable I think this is more straightforward than that. Still, I will experiment and get back if I can manage to create something like that.

ElecTwix commented 3 months ago

Hi @phughk,

After some testing, I've added a channel-based version of the implementation. I'm not sure if it's an improvement, and I hesitated to include it here since it might not be accepted. However, here's the commit for reference: https://github.com/ElecTwix/surrealdb.go/commit/908a377794436715b35dac3dd7ff2af488c4f5af