storefactory

package
v0.0.0-...-90365bb Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// If not empty, used from OpenString. All else ignored.
	Spec string `envconfig:"SPEC" json:"spec"`

	// If Type is empty, will try to use FromDefault.
	Type string `envconfig:"TYPE" json:"type"`

	GRPC  GRPCConfig         `envconfig:"GRPC" json:"grpc"`   // type="grpc"
	GORM  gormfactory.Config `envconfig:"GORM" json:"gorm"`   // type="gorm"
	Redis RedisConfig        `envconfig:"REDIS" json:"redis"` // type="redis"
	InMem InMemConfig        `envconfig:"INMEM" json:"inmem"` // type="inmem"
	FS    FSConfig           `envconfig:"FS" json:"fs"`       // type="fs"
	Other OtherConfig        `envconfig:"OTHER" json:"other"` // otherwise
}

func ParseConfigString

func ParseConfigString(text string) *Config

func (Config) IsSet

func (c Config) IsSet() bool

type FSConfig

type FSConfig struct {
	Options  map[string]string `envconfig:"OPTIONS" json:"options"`
	RootPath string            `envconfig:"ROOT_PATH" json:"root_path"`
}

type Factory

type Factory struct {
	FromDefault  func(context.Context, L.L) (interface{}, error)
	FromGORM     func(_ context.Context, _ L.L, _ *gorm.DB) (interface{}, error)
	FromGRPCConn func(context.Context, L.L, *grpc.ClientConn) (interface{}, error)
	FromRedis    func(context.Context, L.L, *redis.Client) (interface{}, error)
	FromInMem    func(context.Context, L.L, *InMemConfig) (interface{}, error)
	FromFS       func(context.Context, L.L, *FSConfig) (interface{}, error)
	FromOther    func(context.Context, L.L, string, *OtherConfig) (interface{}, error)
}

func (*Factory) MustOpen

func (f *Factory) MustOpen(ctx context.Context, l L.L, cfg *Config) interface{}

func (*Factory) MustOpenString

func (f *Factory) MustOpenString(ctx context.Context, l L.L, text string) interface{}

func (*Factory) Open

func (f *Factory) Open(ctx context.Context, l L.L, cfg *Config) (interface{}, error)

func (*Factory) OpenString

func (f *Factory) OpenString(ctx context.Context, l L.L, text string) (interface{}, error)

type GRPCConfig

type GRPCConfig struct {
	HostPort string `envconfig:"HOSTPORT" default:"127.0.0.1:20001" json:"hostport"`
}

type InMemConfig

type InMemConfig struct {
	Config string `envconfig:"CONFIG" json:"config"`
}

type OtherConfig

type OtherConfig struct {
	Config string `envconfig:"CONFIG" json:"config"`
}

type RedisConfig

type RedisConfig struct {
	URL string `envconfig:"URL" default:"redis://localhost:6789/0" json:"url"`
}

Jump to

Keyboard shortcuts

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