snowflakeapi

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultTries = 3
)
View Source
var (
	// NewSnowflakeNode func(int64) (idpkg.Snowflake, error)
	// idpkg.NewSonySonyflake
	// idpkg.NewBwmarrinSnowflake
	NewSnowflakeNode = idpkg.NewSonySonyflake
)

Functions

func GetIDGeneratorFromIPV4 added in v0.0.16

func GetIDGeneratorFromIPV4(opts ...Option) (idpkg.Snowflake, func(), error)

func GetSingletonIDGeneratorByGRPCAPI added in v0.0.16

func GetSingletonIDGeneratorByGRPCAPI(serviceAPIManager clientutil.ServiceAPIManager, req *nodeidresourcev1.GetNodeIdReq, opts ...Option) (idpkg.Snowflake, func(), error)

func GetSingletonIDGeneratorByHTTPAPI added in v0.0.16

func GetSingletonIDGeneratorByHTTPAPI(serviceAPIManager clientutil.ServiceAPIManager, req *nodeidresourcev1.GetNodeIdReq, opts ...Option) (idpkg.Snowflake, func(), error)

func GetSingletonSnowflakeNode added in v0.0.9

func GetSingletonSnowflakeNode(idManager IDManager, req *nodeidresourcev1.GetNodeIdReq) (idpkg.Snowflake, func(), error)

GetSingletonSnowflakeNode 获取节点 http GetSingletonIDGeneratorByHTTPAPI grpc GetSingletonIDGeneratorByGRPCAPI

func SetSnowflake added in v0.0.9

func SetSnowflake(node idpkg.Snowflake) error

Types

type IDManager added in v0.0.9

type IDManager interface {
	GetSingletonSnowflakeNode(ctx context.Context, req *nodeidresourcev1.GetNodeIdReq) (idpkg.Snowflake, func(), error)
	GetSnowflakeNode(ctx context.Context, req *nodeidresourcev1.GetNodeIdReq) (idpkg.Snowflake, func(), error)
	SetSnowflakeNode(ctx context.Context, req *nodeidresourcev1.GetNodeIdReq) (idpkg.Snowflake, func(), error)
}

func NewIDManager added in v0.0.9

func NewIDManager(logger log.Logger, helper nodeidapi.NodeIDHelper) IDManager

type Option

type Option func(*options)

func DefaultOptions added in v0.0.12

func DefaultOptions(logger log.Logger) []Option

func WithGetNodeIdFromIPV4 added in v0.0.9

func WithGetNodeIdFromIPV4(isGetNodeIDFromIPV4 bool) Option

func WithLogger

func WithLogger(logger log.Logger) Option

func WithMustGetNodeIdFromAPI added in v0.0.9

func WithMustGetNodeIdFromAPI(mustGetNodeIdForAPI bool) Option

func WithNodeEpoch added in v0.0.10

func WithNodeEpoch(nodeEpoch time.Time) Option

func WithServerName

func WithServerName(serverName clientutil.ServiceName) Option

type SnowflakeNodeInfo added in v0.0.9

type SnowflakeNodeInfo struct {
	Node    idpkg.Snowflake
	Cleanup func()
}

Jump to

Keyboard shortcuts

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