init project

This commit is contained in:
admin committed 2025-12-05 17:23:29 +08:00
commit d63cc8d9f5
33 files changed
+1529

No files matched your search

+68
View File
@@ -0,0 +1,68 @@
package logic
import (
"git.xiaotuo.co/micro/skeleton/internal/storage"
"github.com/nats-io/nats.go"
)
var Resources *resources
type resources struct {
Env string
Server string
JetStreamBroker nats.JetStreamContext
MessageLogic MessageLogic
}
func Init(opts ...Option) error {
options := &Options{}
for _, o := range opts {
o(options)
}
Resources = &resources{
Env: options.env,
Server: options.server,
JetStreamBroker: options.jetStreamBr,
MessageLogic: newMessageLogic(),
}
return nil
}
type Option func(o *Options)
type Options struct {
env string
server string
etcdServer string
st *storage.Storage
jetStreamBr nats.JetStreamContext
tiktokAuthGateway string
}
func WithEnv(env string) Option {
return func(o *Options) {
o.env = env
}
}
func WithStorage(st *storage.Storage) Option {
return func(o *Options) {
o.st = st
}
}
func WithEtcdServer(etcdServer string) Option {
return func(o *Options) {
o.etcdServer = etcdServer
}
}
func WithJetStreamBroker(br nats.JetStreamContext) Option {
return func(o *Options) {
o.jetStreamBr = br
}
}