mirror of
https://github.com/singchia/frontier.git
synced 2025-10-05 16:26:50 +08:00
54 lines
1.0 KiB
Go
54 lines
1.0 KiB
Go
package edge
|
|
|
|
import (
|
|
"github.com/jumboframes/armorigo/log"
|
|
|
|
"github.com/singchia/go-timer/v2"
|
|
)
|
|
|
|
type Logger log.Logger
|
|
type Timer timer.Timer
|
|
|
|
type edgeOption struct {
|
|
logger Logger
|
|
tmr Timer
|
|
edgeID *uint64
|
|
meta []byte
|
|
readBufferSize, writeBufferSize int
|
|
}
|
|
|
|
type EdgeOption func(*edgeOption)
|
|
|
|
func OptionEdgeLog(logger Logger) EdgeOption {
|
|
return func(opt *edgeOption) {
|
|
opt.logger = logger
|
|
}
|
|
}
|
|
|
|
// Pre set timer for the sdk
|
|
func OptionEdgeTimer(tmr Timer) EdgeOption {
|
|
return func(opt *edgeOption) {
|
|
opt.tmr = tmr
|
|
}
|
|
}
|
|
|
|
// Pre set EdgeID for the sdk
|
|
func OptionEdgeID(edgeID uint64) EdgeOption {
|
|
return func(opt *edgeOption) {
|
|
opt.edgeID = &edgeID
|
|
}
|
|
}
|
|
|
|
func OptionEdgeMeta(meta []byte) EdgeOption {
|
|
return func(opt *edgeOption) {
|
|
opt.meta = meta
|
|
}
|
|
}
|
|
|
|
func OptionServiceBufferSize(read, write int) EdgeOption {
|
|
return func(opt *edgeOption) {
|
|
opt.readBufferSize = read
|
|
opt.writeBufferSize = write
|
|
}
|
|
}
|