Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrCouldNotResolveCacheCluster = errRange.New( "Invalid Cache Keyspace Construction", `Could not resolve the cache cluster: must refer to a package level variable.`, ) ErrDuplicateCacheCluster = errRange.New( "Duplicate Cache Cluster", "Cache clusters must have unique names.", errors.PrependDetails("I you wish to reuse the same cluster, export the original cache.Cluster object and reuse it here."), ) ErrKeyspaceNotInService = errRange.New( "Invalid Cache Keyspace", "Cache keyspaces must be defined within a service.", ) ErrKeyspaceUsedInOtherService = errRange.New( "Invalid Cache Keyspace Usage", "Cache keyspaces must be used within the same service they are defined in.", ) )
View Source
var ClusterParser = &resourceparser.Parser{ Name: "Cache Cluster", InterestingImports: []paths.Pkg{"encore.dev/storage/cache"}, Run: func(p *resourceparser.Pass) { name := pkginfo.QualifiedName{PkgPath: "encore.dev/storage/cache", Name: "NewCluster"} spec := &parseutil.ReferenceSpec{ MinTypeArgs: 0, MaxTypeArgs: 0, Parse: parseCluster, } parseutil.FindPkgNameRefs(p.Pkg, []pkginfo.QualifiedName{name}, func(file *pkginfo.File, name pkginfo.QualifiedName, stack []ast.Node) { parseutil.ParseReference(p, spec, parseutil.ReferenceData{ File: file, Stack: stack, ResourceFunc: name, }) }) }, }
View Source
var KeyspaceParser = &resourceparser.Parser{ Name: "Cache Keyspace", InterestingImports: []paths.Pkg{"encore.dev/storage/cache"}, Run: func(p *resourceparser.Pass) { var ( names []pkginfo.QualifiedName specs = make(map[pkginfo.QualifiedName]*parseutil.ReferenceSpec) ) for _, c := range keyspaceConstructors { name := pkginfo.QualifiedName{PkgPath: "encore.dev/storage/cache", Name: c.FuncName} names = append(names, name) numTypeArgs := 1 if c.ValueKind != implicitValue { numTypeArgs = 2 } c := c parseFn := func(d parseutil.ReferenceInfo) { parseKeyspace(c, d) } spec := &parseutil.ReferenceSpec{ MinTypeArgs: numTypeArgs, MaxTypeArgs: numTypeArgs, Parse: parseFn, } specs[name] = spec } parseutil.FindPkgNameRefs(p.Pkg, names, func(file *pkginfo.File, name pkginfo.QualifiedName, stack []ast.Node) { spec := specs[name] parseutil.ParseReference(p, spec, parseutil.ReferenceData{ File: file, Stack: stack, ResourceFunc: name, }) }) }, }
Functions ¶
func ResolveKeyspaceUsage ¶
func ResolveKeyspaceUsage(data usage.ResolveData, keyspace *Keyspace) usage.Usage
Types ¶
type Cluster ¶
type Cluster struct { AST *ast.CallExpr Name string // The unique name of the cache cluster Doc string // The documentation on the cluster EvictionPolicy string File *pkginfo.File }
func (*Cluster) ResourceName ¶
type Keyspace ¶
type Keyspace struct { AST *ast.CallExpr Doc string // The documentation on the keyspace File *pkginfo.File // File the keyspace is declared in. Cluster pkginfo.QualifiedName KeyType schema.Type ValueType schema.Type Path *resourcepaths.Path // The struct literal for the config. Used to inject additional configuration // at compile-time. ConfigLiteral *ast.CompositeLit }
type KeyspaceUsage ¶
Click to show internal directories.
Click to hide internal directories.