store

package
v0.0.0-...-b1d1417 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const SqlCountComponentById = `
	select count(1) from components t 
	where 1 = 1
		and t.cmp_pkg_path = ? 
		and t.cmp_typ_name = ? 
`
View Source
const SqlDeleteImplementStmtById = `` /* 210-byte string literal not displayed */
View Source
const SqlDeleteProviderById = `
	delete from providers
	where 1 = 1
		and pvd_pkg_path = ?
		and pvd_ori_name = ?
`
View Source
const SqlDeleteProviderRequirementById = `` /* 195-byte string literal not displayed */
View Source
const SqlFindComponentById = `
	select * from components t 
	where 1 = 1
		and t.cmp_pkg_path = ? 
		and t.cmp_typ_name = ? 
`
View Source
const SqlFindImplementStmtById = `` /* 212-byte string literal not displayed */
View Source
const SqlFindProviderRequirementByCmpType = `
	select * from provider_requirements t 
	where 1 = 1
		and t.pvd_pkg_path = ?
		and t.pvd_ori_name = ?
		and t.pvd_kind = ?
`
View Source
const TableComponents = `` /* 214-byte string literal not displayed */

TableComponents 该表存储每个Component的信息

View Source
const TableImplementStmts = `` /* 278-byte string literal not displayed */

TableProvider 该表存储Provider的信息和它所能提供的component

View Source
const TableProviderRequirements = `` /* 427-byte string literal not displayed */

TableProviderRequirement 该表存储Provider的信息和它所需要的所有的components

View Source
const TableProviders = `` /* 321-byte string literal not displayed */

TableProvider 该表存储Provider的信息和它所能提供的component

Variables

This section is empty.

Functions

func Clean

func Clean()

func DeleteComponentByPkg

func DeleteComponentByPkg(pkgPath string) error

func DeleteImplement

func DeleteImplement(impl *ImplementStmt) error

func DeleteProviderByPkg

func DeleteProviderByPkg(pkg string) error

func DeleteProviderRequirementByPkg

func DeleteProviderRequirementByPkg(pkgPath string) error

func Init

func Init()

func Insert

func Insert(value ITable) error

Insert insert value to table

T must be pointer to struct

func NamedSelect

func NamedSelect[T any](query string, args interface{}) ([]T, error)

func SaveComponent

func SaveComponent(c *Component) error

func SaveImplement

func SaveImplement(impl *ImplementStmt) error

func SaveProvider

func SaveProvider(c *Provider) error

func SaveProviderRequirement

func SaveProviderRequirement(c *ProviderRequirement) error

func Select

func Select[T any](query string, args ...interface{}) ([]T, error)

Types

type Component

type Component struct {
	CmpPkgPath string
	CmpPkgName string
	// the type name eg: Book
	CmpTypName string
	CmpName    string
	// struct or interface or primitive types
	CmpKind int
	Labels  string
}

func (*Component) TableName

func (c *Component) TableName() string

type ITable

type ITable interface {
	TableName() string
}

type ImplementStmt

type ImplementStmt struct {
	// component related information
	CmpPkgPath string `db:"cmp_pkg_path"`
	CmpTypName string `db:"cmp_typ_name"`
	// component kind can be found at [types.TypeKind]
	// see /dot/internal/types/util.go
	CmpKind      int    `db:"cmp_kind"`
	IfacePkgPath string `db:"iface_pkg_path"`
	// name is the id field
	IfaceName string `db:"iface_name"`
	Labels    string `db:"labels"`
}

func FindImplementsByImpl

func FindImplementsByImpl(impl *ImplementStmt) ([]ImplementStmt, error)

func FindImplementsByInterface

func FindImplementsByInterface(interfacePackage string, interfaceName string) ([]ImplementStmt, error)

func (*ImplementStmt) TableName

func (*ImplementStmt) TableName() string

type Provider

type Provider struct {
	//
	PvdPkgPath string `db:"pvd_pkg_path"`
	// note that here the package name might be rewrote
	PvdPkgName string `db:"pvd_pkg_name"`
	// the original provider name. typically func name or struct name
	// func named is used to be write to the wire.Set
	PvdOriName string `db:"pvd_ori_name"`
	// name is the id field
	PvdName string `db:"pvd_name"`
	// provider kind, eg: use function or direct a variable
	PvdKind string `db:"pvd_kind"`
	// 1 represent that results contains error
	PvdError int `db:"pvd_error"`
	// component related information
	CmpPkgPath string `db:"cmp_pkg_path"`
	CmpPkgName string `db:"cmp_pkg_name"`
	CmpTypName string `db:"cmp_typ_name"`
	// component kind can be found at [types.TypeKind]
	// see /dot/internal/types/util.go
	CmpKind int    `db:"cmp_kind"`
	Labels  string `db:"labels"`
}

func FindProviderByCmp

func FindProviderByCmp(pkg string, typ string, kind int) ([]Provider, error)

FindProviderByCmp

find suitable providers by component

func FindProviderByName

func FindProviderByName(component string) ([]Provider, error)

FindProviderByCmpName

find suitable provider by component

func FindProviderByPkg

func FindProviderByPkg(pkg string) ([]Provider, error)

FindProviderByPkg

select * from providers t where t.pvd_pkg_path = ?

func (*Provider) Compare

func (a *Provider) Compare(b *Provider) int

func (*Provider) TableName

func (*Provider) TableName() string

type ProviderRequirement

type ProviderRequirement struct {
	PvdPkgPath string `db:"pvd_pkg_path"`
	PvdPkgName string `db:"pvd_pkg_name"`
	PvdOriName string `db:"pvd_ori_name"`
	PvdName    string `db:"pvd_name"`
	PvdKind    string `db:"pvd_kind"`
	CmpPkgPath string `db:"cmp_pkg_path"`
	CmpPkgName string `db:"cmp_pkg_name"`
	CmpTypName string `db:"cmp_typ_name"`
	// multiple params may have same type, thus use param name to distinct each other
	CmpName string `db:"cmp_name"`
	CmpKind int    `db:"cmp_kind"`
	// go:ioc --param name.provider="NewLiu"
	CmpPvdName string `db:"cmp_pvd_name"`
	Labels     string `db:"labels"`
}

ProviderRequirement

func FindProviderRequirements

func FindProviderRequirements(c *Provider) ([]ProviderRequirement, error)

FindProviderRequirements

select * from provider_requirements t
where 1 = 1
	and t.pvd_pkg_path = ?
	and t.pvd_ori_name = ?
	and t.pvd_kind = ?

func (*ProviderRequirement) TableName

func (*ProviderRequirement) TableName() string

type Q

type Q map[string]any

Jump to

Keyboard shortcuts

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