util

package
v1.3.3-testnet Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GracefulShutdown

func GracefulShutdown(wg *sync.WaitGroup, cancel context.CancelFunc)

GracefulShutdown supports to clean up goroutines after termination signal captured.

func StartAndGracefulShutdown

func StartAndGracefulShutdown(run func(ctx context.Context, wg *sync.WaitGroup))

StartAndGracefulShutdown starts to run the specified task in a goroutine and wait for termination signal to shutdown gracefully.

Note, this method is not suitable for any non-blocking task that release resources in defer way.

Types

type GracefulShutdownContext

type GracefulShutdownContext struct {
	Ctx context.Context
	Wg  *sync.WaitGroup
}

GracefulShutdownContext wraps context and wait group which can be utilized to handle graceful shutdown on termination signal received.

type StoreContext

type StoreContext struct {
	CfxDB    *mysql.MysqlStore
	EthDB    *mysql.MysqlStore
	CfxCache *redis.RedisStore
}

StoreContext context to hold store instances

func MustInitStoreContext

func MustInitStoreContext() StoreContext

func (*StoreContext) Close

func (ctx *StoreContext) Close()

func (*StoreContext) GetMysqlStore

func (ctx *StoreContext) GetMysqlStore(network string) (store *mysql.MysqlStore, err error)

GetMysqlStore returns mysql store by network space

type SyncContext

type SyncContext struct {
	StoreContext

	SyncCfx *sdk.Client
	SubCfx  *sdk.Client
	SyncEth *web3go.Client
}

SyncContext context to hold sdk clients for blockchain interoperation.

func MustInitSyncContext

func MustInitSyncContext(storeCtx StoreContext) SyncContext

func (*SyncContext) Close

func (ctx *SyncContext) Close()

Jump to

Keyboard shortcuts

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