add db connection, refactor code, add db migration files
This commit is contained in:
35
internal/foundry/types/ws_channels.go
Normal file
35
internal/foundry/types/ws_channels.go
Normal 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
|
||||
}
|
||||
17
internal/foundry/types/ws_message.go
Normal file
17
internal/foundry/types/ws_message.go
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user