service

package
v0.0.0-...-a69402d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2023 License: MIT Imports: 23 Imported by: 0

README

service

业务逻辑层,处于 server 层和 dao 层之间。service 只能通过 dao 层获取数据。

业务接口必须接受 ctx context.Context 对象,并向下传递。

错误日志

框架支持自动打印错误日志,使用方法:

import "github.com/busyfree/leaf-go/util/errors"

// ...

return errors.Wrap(err)
// 如果有附加信息,则可以
return errors.Wrap(err, "extram msg")

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PREFIX_ZK_PATH = "/snowflake/" + conf.GetString("LEAF_NAME")
	PROP_PATH      = filepath.Join(conf.GetConfigPath(), conf.GetString("LEAF_NAME")) + "/leafconf/{port}/workerID.toml"
	PATH_FOREVER   = PREFIX_ZK_PATH + "/forever" // 保存所有数据持久的节点

)

Functions

func SyncXORMTables

func SyncXORMTables()

Types

type Endpoint

type Endpoint struct {
	IP        string `json:"ip"`
	Port      string `json:"port"`
	Timestamp int64  `json:"timestamp"`
}

type IDGen

type IDGen interface {
	Get(ctx context.Context, key string) models.Result
	Init(ctx context.Context) bool
}

type LeafAllocService

type LeafAllocService struct {
	Dao *dao.LeafAllocDao
}

func NewLeafAllocService

func NewLeafAllocService() *LeafAllocService

func (*LeafAllocService) GetAllLeafAllocs

func (s *LeafAllocService) GetAllLeafAllocs(ctx context.Context) (array []*dao.LeafAllocDao, err error)

func (*LeafAllocService) GetAllTags

func (s *LeafAllocService) GetAllTags(ctx context.Context) (array []string, err error)

func (*LeafAllocService) GetLeafAlloc

func (s *LeafAllocService) GetLeafAlloc(ctx context.Context, tag string) (err error)

func (*LeafAllocService) UpdateMaxId

func (s *LeafAllocService) UpdateMaxId(ctx context.Context, tag string) (err error)

func (*LeafAllocService) UpdateMaxIdByCustomStep

func (s *LeafAllocService) UpdateMaxIdByCustomStep(ctx context.Context, step int, tag string) (err error)

type SegmentIDGenImpl

type SegmentIDGenImpl struct {
	// contains filtered or unexported fields
}

func NewSegmentIDGenImpl

func NewSegmentIDGenImpl() *SegmentIDGenImpl

func (*SegmentIDGenImpl) Get

func (*SegmentIDGenImpl) GetAllLeafAllocs

func (s *SegmentIDGenImpl) GetAllLeafAllocs(ctx context.Context) (array []*dao.LeafAllocDao, err error)

func (*SegmentIDGenImpl) GetCache

func (s *SegmentIDGenImpl) GetCache(ctx context.Context) *sync.Map

func (*SegmentIDGenImpl) GetDao

func (*SegmentIDGenImpl) Init

func (s *SegmentIDGenImpl) Init() bool

func (*SegmentIDGenImpl) SetDao

func (s *SegmentIDGenImpl) SetDao(dao *dao.LeafAllocDao)

type SnowFlakeEtcdHolder

type SnowFlakeEtcdHolder struct {
	WorkerId int
	// contains filtered or unexported fields
}

func NewSnowFlakeEtcdHolder

func NewSnowFlakeEtcdHolder(ip, port string, endpoints []string, dialTimeout int) *SnowFlakeEtcdHolder

func (*SnowFlakeEtcdHolder) GetWorkerId

func (s *SnowFlakeEtcdHolder) GetWorkerId() int

func (*SnowFlakeEtcdHolder) Init

func (s *SnowFlakeEtcdHolder) Init() bool

type SnowFlakeIdGenImpl

type SnowFlakeIdGenImpl struct {
	// contains filtered or unexported fields
}

func NewSnowFlakeIdGenImpl

func NewSnowFlakeIdGenImpl(port int, twepoch int64) *SnowFlakeIdGenImpl

func (*SnowFlakeIdGenImpl) DecodeSnowflakeId

func (s *SnowFlakeIdGenImpl) DecodeSnowflakeId(idStr string) map[string]interface{}

func (*SnowFlakeIdGenImpl) Get

func (*SnowFlakeIdGenImpl) Init

func (s *SnowFlakeIdGenImpl) Init(ctx context.Context) bool

type SnowFlakeZookeeperHolder

type SnowFlakeZookeeperHolder struct {
	ZKAddressNode string

	WorkerId int
	// contains filtered or unexported fields
}

func NewSnowFlakeZookeeperHolder

func NewSnowFlakeZookeeperHolder(ip, port, connectionStr string) *SnowFlakeZookeeperHolder

func (*SnowFlakeZookeeperHolder) GetWorkerId

func (s *SnowFlakeZookeeperHolder) GetWorkerId() int

func (*SnowFlakeZookeeperHolder) Init

func (s *SnowFlakeZookeeperHolder) Init() bool

type ZeroIDGenImpl

type ZeroIDGenImpl struct {
}

func NewZeroIDGenImpl

func NewZeroIDGenImpl() *ZeroIDGenImpl

func (*ZeroIDGenImpl) Get

func (s *ZeroIDGenImpl) Get(ctx context.Context, key string) models.Result

func (*ZeroIDGenImpl) Init

func (s *ZeroIDGenImpl) Init(ctx context.Context) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL