Files
frontier/api/dataplane/v1/edge/edge_option.go
2024-05-26 06:00:03 -04:00

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
}
}