You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
483 B
Go
23 lines
483 B
Go
2 years ago
|
package plain
|
||
|
|
||
|
import (
|
||
|
"git.noahlan.cn/noahlan/nnet/core"
|
||
|
"git.noahlan.cn/noahlan/nnet/entity"
|
||
|
"git.noahlan.cn/noahlan/nnet/packet"
|
||
|
)
|
||
|
|
||
|
func withPipeline() core.RunOption {
|
||
|
return func(net *core.NNet) {
|
||
|
net.Pipeline().Inbound().PushFront(func(et entity.NetworkEntity, v interface{}) error {
|
||
|
_, ok := v.(*Packet)
|
||
|
if !ok {
|
||
|
return packet.ErrWrongPacketType
|
||
|
}
|
||
|
if et.Status() != core.StatusWorking {
|
||
|
et.SetStatus(core.StatusWorking)
|
||
|
}
|
||
|
return nil
|
||
|
})
|
||
|
}
|
||
|
}
|