dataRT/data/data.go

43 lines
729 B
Go
Raw Normal View History

2025-09-19 16:17:46 +08:00
package data
2025-10-23 18:02:29 +08:00
import (
"context"
"datart/data/influx"
2025-11-20 20:58:51 +08:00
"datart/data/mongo"
2025-11-06 21:09:50 +08:00
"datart/data/postgres"
2025-11-20 20:58:51 +08:00
"datart/data/rabbit"
"datart/data/redis"
"datart/log"
2025-10-23 18:02:29 +08:00
)
2025-11-20 20:58:51 +08:00
type Processes struct {
2025-10-23 18:02:29 +08:00
cancel context.CancelFunc
}
2025-11-20 20:58:51 +08:00
func NewProcesses() *Processes {
return new(Processes)
2025-10-23 18:02:29 +08:00
}
2025-11-20 20:58:51 +08:00
func (p *Processes) StartDataProcessing() {
2025-10-23 18:02:29 +08:00
ctx, cancel := context.WithCancel(context.Background())
p.cancel = cancel
2025-11-20 20:58:51 +08:00
if err := postgres.GenSSU2ChannelSizes(ctx, 500); err != nil {
log.Error(err)
}
2025-10-23 18:02:29 +08:00
2025-11-20 20:58:51 +08:00
updatingRedisPhasor(ctx)
2025-10-23 18:02:29 +08:00
}
2025-11-20 20:58:51 +08:00
func (p *Processes) Cancel(ctx context.Context) {
p.cancel()
2025-10-23 18:02:29 +08:00
2025-11-20 20:58:51 +08:00
eventNotifyPublisher.Close(ctx)
2025-10-23 18:02:29 +08:00
2025-11-20 20:58:51 +08:00
influx.CloseDefault()
mongo.CloseDefault(ctx)
postgres.CloseDefault()
rabbit.CloseDefault(ctx)
redis.CloseDefault()
2025-10-23 18:02:29 +08:00
}