goProject/trunk/goutil/ensureSendUtil/bytesSendUtil/baseSender.go
皮蛋13361098506 1b77f62820 初始化项目
2025-01-06 16:01:02 +08:00

55 lines
1.0 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package bytesSendUtil
import (
"fmt"
)
/*
实现sender接口
*/
type baseSender struct {
// 待发送的数据channel
waitingDataChan chan dataItem
// 失败数据缓存
cachedDataChan chan dataItem
// 用于停止协程
done chan struct{}
}
func newBaseSender() *baseSender {
return &baseSender{
waitingDataChan: make(chan dataItem, 1024),
cachedDataChan: make(chan dataItem, 1024000),
done: make(chan struct{}),
}
}
// Sender接口
// Send:
func (this *baseSender) Send() error {
// baseSender不实现发送
// 由tcpSender和httpSender实现发送
return fmt.Errorf("baseSender dose not have Send Method")
}
// Sender接口
// Data: 返回待发送的数据channel
func (this *baseSender) Data() <-chan dataItem {
return this.waitingDataChan
}
// Sender接口
// Cache返回失败数据缓存channel
func (this *baseSender) Cache() chan dataItem {
return this.cachedDataChan
}
// Sender接口
// Done返回channel用于判断是否关闭
func (this *baseSender) Done() <-chan struct{} {
return this.done
}