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 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 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.