Documentation
¶
Overview ¶
Package entrypoint holds the parts of module entrypoint loading that every entrypoint driver shares: resolving entrypoint.source to a module source, encoding the arguments of the ModuleEntrypoint interface, and turning the type definitions an entrypoint returns into a module.
The one driver lives next to it: dang evaluates the entrypoint source as a Dang program.
Index ¶
- Constants
- func FindConfigFile(ctx context.Context, dag *dagql.Server, src *core.ModuleSource, name string) (path string, contents []byte, found bool, rerr error)
- func FindConfigFileInContext(ctx context.Context, contextDir dagql.ObjectResult[*core.Directory], ...) (path string, contents []byte, found bool, rerr error)
- func FunctionArgsJSON(args []*core.FunctionCallArgValue) (core.JSON, error)
- func IsLocalSource(ctx context.Context, src *core.ModuleSource) (bool, error)
- func JSONCallArg(name string, value core.JSON) *core.FunctionCallArgValue
- func JSONScalarCallArg(name string, value core.JSON) *core.FunctionCallArgValue
- func LocalDirectory(ctx context.Context, dag *dagql.Server, src *core.ModuleSource) (dagql.ObjectResult[*core.Directory], bool, error)
- func ModuleFromTypeDefs(ctx context.Context, dag *dagql.Server, ...) (dagql.ObjectResult[*core.Module], error)
- func ResolveSource(ctx context.Context, dag *dagql.Server, ...) (dagql.ObjectResult[*core.ModuleSource], error)
- func SourceForDirectory(src *core.ModuleSource, directory dagql.ObjectResult[*core.Directory]) *core.ModuleSource
- func SourcesWorkspace(ctx context.Context, dag *dagql.Server, src *core.ModuleSource) (dagql.ObjectResult[*core.Workspace], error)
- func StringCallArg(name, value string) *core.FunctionCallArgValue
- func ValidateConstructors(typeDefs dagql.ObjectResultArray[*core.TypeDef]) error
- func Workspace(ctx context.Context, dag *dagql.Server, ...) (dagql.ObjectResult[*core.Workspace], error)
- func WorkspaceCallArg(workspace dagql.ObjectResult[*core.Workspace]) (*core.FunctionCallArgValue, error)
Constants ¶
const TypeName = "ModuleEntrypoint"
TypeName is the interface an entrypoint must implement.
Variables ¶
This section is empty.
Functions ¶
func FindConfigFile ¶
func FindConfigFile( ctx context.Context, dag *dagql.Server, src *core.ModuleSource, name string, ) (path string, contents []byte, found bool, rerr error)
FindConfigFile finds the file called name that governs the entrypoint source, the way Dang finds a dang.toml: the nearest one in the entrypoint directory or above it, but never above the module directory. It returns the file's path and contents, or found false when there is none.
For a local entrypoint the search walks up from the entrypoint directory to the module directory, which every module context holds whole, so the file it finds is the same however the module was loaded, and is part of the module digest. A file above the module directory never counts: a local or Git module context holds only the module's own files there, while a directory source holds whatever its caller passed. A local path that is invalid or missing has no file; the module's types call reports it.
A module reference or an address names the entrypoint directory itself, and the search does not leave it: only the directory's own file counts. Finding it resolves the directory, which the module's types call would do anyway.
func FindConfigFileInContext ¶
func FindConfigFileInContext( ctx context.Context, contextDir dagql.ObjectResult[*core.Directory], from string, moduleDir string, name string, ) (path string, contents []byte, found bool, rerr error)
FindConfigFileInContext finds the file called name nearest to the directory from of contextDir, walking up from it to moduleDir and never above it, the way Dang finds a dang.toml within a module. When from is not inside moduleDir, only from's own file counts. It returns the file's path in contextDir and its contents, or found false when there is none, or when from does not exist.
func FunctionArgsJSON ¶
func FunctionArgsJSON(args []*core.FunctionCallArgValue) (core.JSON, error)
FunctionArgsJSON encodes call arguments as one JSON object, keyed by the original argument names.
func IsLocalSource ¶
IsLocalSource reports whether entrypoint.source is a path inside the module.
func JSONCallArg ¶
func JSONCallArg(name string, value core.JSON) *core.FunctionCallArgValue
JSONCallArg builds an argument from an already encoded JSON value.
func JSONScalarCallArg ¶
func JSONScalarCallArg(name string, value core.JSON) *core.FunctionCallArgValue
JSONScalarCallArg builds a JSON scalar argument, which the call codec passes as a JSON-encoded string.
func LocalDirectory ¶
func LocalDirectory( ctx context.Context, dag *dagql.Server, src *core.ModuleSource, ) (dagql.ObjectResult[*core.Directory], bool, error)
LocalDirectory returns the entrypoint directory when entrypoint.source is a path inside the module that exists in its context. For an address, a module reference, or a path that is invalid or missing, it returns false and leaves any error to the module's types call.
func ModuleFromTypeDefs ¶
func ModuleFromTypeDefs( ctx context.Context, dag *dagql.Server, typeDefs dagql.ObjectResultArray[*core.TypeDef], ) (dagql.ObjectResult[*core.Module], error)
ModuleFromTypeDefs builds a module from the types an entrypoint returned.
func ResolveSource ¶
func ResolveSource( ctx context.Context, dag *dagql.Server, src dagql.ObjectResult[*core.ModuleSource], ) (dagql.ObjectResult[*core.ModuleSource], error)
ResolveSource resolves entrypoint.source to a module source for the entrypoint itself.
func SourceForDirectory ¶
func SourceForDirectory(src *core.ModuleSource, directory dagql.ObjectResult[*core.Directory]) *core.ModuleSource
SourceForDirectory returns a clone of src whose whole context is the entrypoint directory.
func SourcesWorkspace ¶
func SourcesWorkspace( ctx context.Context, dag *dagql.Server, src *core.ModuleSource, ) (dagql.ObjectResult[*core.Workspace], error)
SourcesWorkspace returns the workspace to pass to an entrypoint's sources member. Its root is the module's context root and its working directory is the module directory, so a Directory built from the workspace root has the module at SourceRootSubpath, where the module context has it.
The workspace reads the module's own source: the workspace that loaded it, the host checkout of a local module, or the tree of a Git or directory module. It is never the caller's workspace for a module from elsewhere.
func StringCallArg ¶
func StringCallArg(name, value string) *core.FunctionCallArgValue
StringCallArg builds a JSON-encoded string argument.
func ValidateConstructors ¶
func ValidateConstructors(typeDefs dagql.ObjectResultArray[*core.TypeDef]) error
ValidateConstructors applies the engine's current limit of at most one object constructor per module.
func Workspace ¶
func Workspace( ctx context.Context, dag *dagql.Server, src dagql.ObjectResult[*core.ModuleSource], ) (dagql.ObjectResult[*core.Workspace], error)
Workspace returns the workspace to pass to a module entrypoint, with its working directory at the module's directory.
The engine already treats the workspace cwd as the module's scope when it hands a workspace to an SDK, so an entrypoint can find the module it serves through relative workspace paths, without a path generated into it. The root is unchanged: an entrypoint can still read above the module with an absolute workspace path.
A git or directory source keeps the caller's cwd, because its files are not in the workspace at all; they are in its context directory.
func WorkspaceCallArg ¶
func WorkspaceCallArg(workspace dagql.ObjectResult[*core.Workspace]) (*core.FunctionCallArgValue, error)
WorkspaceCallArg encodes the workspace argument shared by types and call.
Types ¶
This section is empty.