Ripped out literally everything to simplify the backend as much as possible. Some of the code was so horrifically complicated it's insaneeee
20 lines
407 B
Go
20 lines
407 B
Go
package processor
|
|
|
|
type Processor[TMessage any] struct {
|
|
queue chan TMessage
|
|
process func(message TMessage)
|
|
}
|
|
|
|
func (p *Processor[TMessage]) Work() {
|
|
for msg := range p.queue {
|
|
p.process(msg)
|
|
}
|
|
}
|
|
|
|
func NewProcessor[TMessage any](bufferSize int, process func(message TMessage)) *Processor[TMessage] {
|
|
return &Processor[TMessage]{
|
|
queue: make(chan TMessage, bufferSize),
|
|
process: process,
|
|
}
|
|
}
|