add db connection, refactor code, add db migration files

This commit is contained in:
lbenedar
2026-04-03 18:59:15 +03:00
parent d5577f10d7
commit a16edb9b61
28 changed files with 587 additions and 345 deletions

View File

@@ -0,0 +1,35 @@
package types
type Channels struct {
done chan struct{}
msg chan *WsMessage
err chan error
}
func (channels Channels) Err() chan error {
return channels.err
}
func (channels Channels) Msg() chan *WsMessage {
return channels.msg
}
func (channels Channels) Done() chan struct{} {
return channels.done
}
func (channels *Channels) Close() {
close(channels.done)
close(channels.err)
close(channels.msg)
}
func InitWsChannels() *Channels {
channels := Channels{
done: make(chan struct{}),
err: make(chan error, 10),
msg: make(chan *WsMessage, 10),
}
return &channels
}

View File

@@ -0,0 +1,17 @@
package types
import "fmt"
type WsMessage struct {
Code string
Id int
MsgJson string
}
func (w WsMessage) ToString() string {
return fmt.Sprintf("%s%d%s", w.Code, w.Id, w.MsgJson)
}
func (w WsMessage) ToByteSlice() []byte {
return fmt.Appendf([]byte{}, "%s%d%s", w.Code, w.Id, w.MsgJson)
}