infra

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Coco

type Coco struct{}

infra.Coco 可用于嵌入,用于自定义的 infra 实例

func (Coco) CocoInfra

func (i Coco) CocoInfra()

type Elastic

type Elastic struct {
	*elasticsearch.Client
	Coco
}

func NewElastic

func NewElastic(cfg ElasticConfig) (*Elastic, error)

NewElastic provides a new Elastic client

type ElasticConfig

type ElasticConfig struct {
	Addresses []string
	Username  string
	Password  string
}

type Infra

type Infra interface {
	CocoInfra() // 用于标记特定的接口实现方式
}

Infra 带有初始化逻辑的基础设施等

type KafkaMessage

type KafkaMessage = kafka.Message

type KafkaReader

type KafkaReader struct {
	*kafka.Reader
	Coco
}

KafkaReader is a wrapper of kafka reader.

func NewKafkaReader

func NewKafkaReader(c KafkaReaderConfig) (*KafkaReader, error)

NewKafkaReader creates a new kafka reader.

type KafkaReaderConfig

type KafkaReaderConfig struct {
	Brokers     []string
	Topic       string
	GroupID     string
	GroupTopics []string
}

type KafkaWriter

type KafkaWriter struct {
	*kafka.Writer
	Coco
}

KafkaWriter is a wrapper of kafka writer.

func NewKafkaWriter

func NewKafkaWriter(c KafkaWriterConfig) (*KafkaWriter, error)

NewKafkaWriter creates a new kafka writer.

type KafkaWriterConfig

type KafkaWriterConfig struct {
	Brokers      []string
	Topic        string
	ClientID     string
	DialTimeout  time.Duration
	BatchTimeout time.Duration
	Async        bool
}

type Mongo

type Mongo struct {
	*mongo.Client
	Coco
}

func NewMongo

func NewMongo(c MongoConfig) (*Mongo, error)

NewMongo provides a new Mongo client

func (*Mongo) WithTransaction

func (m *Mongo) WithTransaction(ctx context.Context, fn TransactionFn) (interface{}, error)

type MongoConfig

type MongoConfig struct {
	URL             string
	ConnectTimeout  time.Duration // 初始化连接超时时间
	SocketTimeout   time.Duration
	MaxConnIdleTime time.Duration
	MaxPoolSize     uint64
}

type Postgres

type Postgres struct {
	*pg.DB
	Coco
}

func NewPostgres

func NewPostgres(cfg PostgresConfig) (*Postgres, func(), error)

NewPostgres provides a new Postgres client

type PostgresConfig

type PostgresConfig struct {
	Addr     string
	User     string
	Password string
	Database string
}

type Redis

type Redis struct {
	*redis.Client
	Coco
}

func NewRedis

func NewRedis(cfg RedisConfig) (*Redis, error)

NewRedis provides a new Redis client

type RedisConfig

type RedisConfig struct {
	URL            string
	ConnectTimeout time.Duration // 初始化连接超时时间
}

type Sentry

type Sentry struct {
	Coco
}

func NewSentry

func NewSentry(opts sentry.ClientOptions) (*Sentry, error)

type TransactionFn

type TransactionFn = func(sessionContext mongo.SessionContext) (interface{}, error)

Jump to

Keyboard shortcuts

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