Files
atomctl/templates/providers/hashids/hashids.go.tpl
Rogee 342f205b5e feat(tracing): Implement Jaeger/OpenTracing provider with configuration options
- Added Punycode encoding implementation for cookie handling.
- Introduced serialization for cookie jar with JSON support.
- Created a comprehensive README for the tracing provider, detailing configuration and usage.
- Developed a configuration structure for tracing, including sampler and reporter settings.
- Implemented the provider logic to initialize Jaeger tracer with logging capabilities.
- Ensured graceful shutdown of the tracer on application exit.
2025-09-12 17:28:25 +08:00

36 lines
762 B
Smarty

package hashids
import (
"go.ipao.vip/atom/container"
"go.ipao.vip/atom/opt"
"github.com/speps/go-hashids/v2"
)
func Provide(opts ...opt.Option) error {
o := opt.New(opts...)
var config Config
if err := o.UnmarshalConfig(&config); err != nil {
return err
}
return container.Container.Provide(func() (*hashids.HashID, error) {
data := hashids.NewData()
data.MinLength = int(config.MinLength)
if data.MinLength == 0 {
data.MinLength = 10
}
data.Salt = config.Salt
if data.Salt == "" {
data.Salt = "default-salt-key"
}
data.Alphabet = config.Alphabet
if config.Alphabet == "" {
data.Alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
}
return hashids.NewWithData(data)
}, o.DiOptions()...)
}