target

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Log             = "_log"
	Sleep           = "_sleep"
	ServiceRegister = "_astral_service_register"
	ServiceClose    = "_astral_service_close"
	ConnAccept      = "_astral_conn_accept"
	ConnClose       = "_astral_conn_close"
	ConnWrite       = "_astral_conn_write"
	ConnRead        = "_astral_conn_read"
	Query           = "_astral_query"
	QueryName       = "_astral_query_name"
	GetNodeInfo     = "_astral_node_info"
	ResolveId       = "_astral_resolve"
	Interrupt       = "_astral_interrupt"
)
View Source
const BuildFilename = "dev.portal"
View Source
const ManifestFilename = "portal"
View Source
const PackageJsonFilename = "package"
View Source
const TemplateInfoFileName = "template.json"

Variables

View Source
var ErrNotFound = errors.New("no targets found")
View Source
var ErrNotTarget = errors.New("not a target")
View Source
var PortMsg = PortPortal.Route("broadcast")
View Source
var PortOpen = PortPortal.Route("open")
View Source
var PortPortal = NewPort("portal")

Functions

func Abs

func Abs(src string) string

func CacheDir added in v0.1.1

func CacheDir(name string) (dir string)

func Combine added in v0.1.0

func Combine[A any, T any](of ...func(A) (A, error)) func(A) (T, error)

func List added in v0.1.0

func List[T any](resolve Resolve[T], from ...Source) (out []T)

List all Source from a given dir.

func Match added in v0.1.0

func Match[T any](arg Portal_) (ok bool)

func Skip

func Skip(names ...string) func(source Source) (result Source, err error)

func Sprint added in v0.1.1

func Sprint(source Portal_) string

Types

type App

type App[T any] interface {
	Portal[T]
	IsApp()
}

type AppBundle added in v0.1.0

type AppBundle[T any] interface {
	Package() Source
	App[T]
}

type AppExec

type AppExec App[Exec]

type AppHtml

type AppHtml App[Html]

type AppJs

type AppJs App[Js]

type App_ added in v0.1.0

type App_ interface {
	Portal_
	IsApp()
}

type Apphost

type Apphost interface {
	ApphostCache
	ApphostApi
}

type ApphostApi

type ApphostApi interface {
	Close() error
	Interrupt()
	Log(arg ...any)
	LogArr(arg []any)
	Sleep(duration int64)
	ServiceRegister(service string) (err error)
	ServiceClose(service string) (err error)
	ConnAccept(service string) (data string, err error)
	ConnClose(id string) (err error)
	ConnWrite(id string, data string) (err error)
	ConnRead(id string) (data string, err error)
	Query(identity string, query string) (data string, err error)
	QueryName(name string, query string) (data string, err error)
	Resolve(name string) (id string, err error)
	NodeInfo(identity string) (info NodeInfo, err error)
}

type ApphostCache

type ApphostCache interface {
	Connections() []ApphostConn
	Listeners() []ApphostListener
	Events() *sig.Queue[ApphostEvent]
}

type ApphostConn

type ApphostConn struct {
	Query string
	In    bool
}

type ApphostEvent

type ApphostEvent struct {
	Type ApphostEventType
	Port string
	Ref  string
}

type ApphostEventType

type ApphostEventType int
const (
	ApphostConnect ApphostEventType = iota
	ApphostDisconnect
	ApphostRegister
	ApphostUnregister
)

type ApphostListener

type ApphostListener struct {
	Port string
}

type Build added in v0.1.1

type Build struct {
	Deps []string `json:"deps,omitempty" yaml:"deps,omitempty"`
	Env  []string `json:"env,omitempty" yaml:"env,omitempty"`
	Cmd  string   `json:"cmd,omitempty" yaml:"cmd,omitempty"`
	Exec string   `json:"exec,omitempty" yaml:"exec,omitempty"`
}

type Builds added in v0.1.1

type Builds map[string]Build

func LoadBuilds added in v0.1.1

func LoadBuilds(source Source) (out Builds)

type Bundle

type Bundle interface {
	Source
	Package() Source
}

type BundleExec

type BundleExec AppBundle[Exec]

type BundleHtml

type BundleHtml AppBundle[Html]

type BundleJs

type BundleJs AppBundle[Js]

type Bundle_ added in v0.1.0

type Bundle_ interface {
	Package() Source
	App_
}

type Cache

type Cache[T Portal_] struct {
	// contains filtered or unexported fields
}

func (*Cache[T]) Add

func (c *Cache[T]) Add(portals []T)

func (*Cache[T]) Get

func (c *Cache[T]) Get(src string) (portal T, ok bool)

func (*Cache[T]) Path added in v0.1.0

func (c *Cache[T]) Path(src string) (path string, err error)

type Dist

type Dist[T any] interface {
	IsDist()
	App[T]
}

type DistExec

type DistExec Dist[Exec]

type DistHtml

type DistHtml Dist[Html]

type DistJs

type DistJs Dist[Js]

type Dist_ added in v0.1.0

type Dist_ interface {
	IsDist()
	App_
}

type Env

type Env struct {
	Timeout int64 `json:"timeout,omitempty" yaml:"timeout,omitempty"`
}

type Event

type Event int
const (
	DevChanged Event = iota
	DevRefreshed
)

type Exec

type Exec interface{ Executable() Source }

type File added in v0.1.0

type File func(path ...string) (source Source, err error)

type Find

type Find[T Portal_] func(ctx context.Context, src string) (portals Portals[T], err error)

func FindByPath added in v0.1.1

func FindByPath[T Portal_](file File, resolve Resolve[T]) Find[T]

func (Find[T]) ById added in v0.1.1

func (find Find[T]) ById(path Path) Find[T]

func (Find[T]) Cached added in v0.1.1

func (find Find[T]) Cached(cache *Cache[T]) Find[T]

func (Find[T]) Call added in v0.1.1

func (find Find[T]) Call(ctx context.Context, src string) (portals Portals[T], err error)

func (Find[T]) Reduced added in v0.1.0

func (find Find[T]) Reduced(priority ...Matcher) Find[T]

type Html

type Html interface{ IndexHtml() }

type Js

type Js interface{ MainJs() }

type Manifest

type Manifest struct {
	Name        string `json:"name,omitempty" yaml:"name,omitempty"`
	Title       string `json:"title,omitempty" yaml:"title,omitempty"`
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	Package     string `json:"package,omitempty" yaml:"package,omitempty"`
	Version     string `json:"version,omitempty" yaml:"version,omitempty"`
	Icon        string `json:"icon,omitempty" yaml:"icon,omitempty"`
	Exec        string `json:"exec,omitempty" yaml:"exec,omitempty"`
	Env         Env    `json:"env,omitempty" yaml:"env,omitempty"`
}

func (Manifest) Match

func (m Manifest) Match(id string) bool

type Matcher added in v0.1.0

type Matcher func(arg Portal_) (ok bool)

type Msg

type Msg struct {
	Pkg   string    `json:"pkg"`
	Event Event     `json:"event"`
	Time  time.Time `json:"time"`
}

func NewMsg

func NewMsg(pkg string, event Event) Msg

type MsgSend

type MsgSend func(msg Msg) error

type MsgSender

type MsgSender func(port Port) MsgSend

type NewApphost

type NewApphost func(ctx context.Context, portal Portal_) Apphost

type NewRuntime added in v0.1.1

type NewRuntime func(context.Context, Portal_) Runtime

type NodeInfo

type NodeInfo struct {
	Identity string
	Name     string
}

type NodeModule

type NodeModule interface {
	Source
	PkgJson() *PackageJson
}

type PackageJson

type PackageJson struct {
	Portal  string `json:"portal,omitempty"`
	Scripts struct {
		Build string `json:"build"`
	} `json:"scripts,omitempty"`
}

func (PackageJson) CanBuild

func (p PackageJson) CanBuild() bool

func (PackageJson) IsPortalLib

func (p PackageJson) IsPortalLib() bool

type Path

type Path func(src string) (path string, err error)

type Port

type Port struct {
	Base string
	Name string
}

func NewPort

func NewPort(base string) Port

func (Port) Copy

func (p Port) Copy(base string) Port

func (Port) Route

func (p Port) Route(name string) Port

func (Port) String

func (p Port) String() string

func (Port) Target

func (p Port) Target(portal Portal_) Port

type Portal

type Portal[T any] interface {
	Portal_
	Target() T
}

type PortalExec added in v0.1.0

type PortalExec Portal[Exec]

type PortalHtml

type PortalHtml Portal[Html]

type PortalJs

type PortalJs Portal[Js]

type Portal_ added in v0.1.0

type Portal_ interface {
	Source
	Manifest() *Manifest
}

type Portals

type Portals[T Portal_] []T

func (Portals[T]) Reduced added in v0.1.0

func (p Portals[T]) Reduced() (reduced Portals[T])

func (Portals[T]) SortBy added in v0.1.0

func (p Portals[T]) SortBy(priority Priority)

type Priority added in v0.1.0

type Priority []Matcher

func (Priority) Get added in v0.1.0

func (priority Priority) Get(app Portal_) int

type Project

type Project[T any] interface {
	Portal[T]
	Build() Builds
	Dist_() Dist_
	Dist() Dist[T]
}

type ProjectExec added in v0.1.0

type ProjectExec Project[Exec]

type ProjectGo

type ProjectGo interface {
	Project[Exec]
	IsGo()
}

type ProjectHtml

type ProjectHtml ProjectNpm[Html]

type ProjectJs

type ProjectJs ProjectNpm[Js]

type ProjectNpm

type ProjectNpm[T any] interface {
	Project[T]
	PkgJson() *PackageJson
}

type ProjectNpm_ added in v0.1.0

type ProjectNpm_ interface {
	Project_
	PkgJson() *PackageJson
}

type Project_ added in v0.1.0

type Project_ interface {
	Portal_
	Build() Builds
	Dist_() Dist_
}

type Request added in v0.1.1

type Request func(ctx context.Context, src string, args ...string) (err error)

func (Request) Start added in v0.1.1

func (r Request) Start(ctx context.Context, src string, args ...string) (err error)

type Resolve

type Resolve[T any] func(src Source) (result T, err error)

func Any

func Any[T Source](of ...func(Source) (Source, error)) Resolve[T]

func Try

func Try[A Source, B Source](f func(A) (B, error)) Resolve[Source]

func (Resolve[T]) List added in v0.1.1

func (resolve Resolve[T]) List(from ...Source) (out []T)

List all Source from a given dir.

func (Resolve[T]) Resolve added in v0.1.1

func (resolve Resolve[T]) Resolve(src Source) (result T, err error)

type Run

type Run[T Source] func(ctx context.Context, src T) (err error)

func (Run[T]) Call added in v0.1.1

func (r Run[T]) Call(ctx context.Context, src T) (err error)

func (Run[T]) Portal

func (r Run[T]) Portal(ctx context.Context, src Portal_) (err error)

type Runner

type Runner[T Portal_] interface {
	Run(ctx context.Context, src T) (err error)
	Reload() error
}

type Runtime added in v0.1.1

type Runtime interface{ Apphost }

type Source

type Source interface {
	Abs() string
	Path() string
	Files() fs.FS
	Sub(dir string) (Source, error)
	IsDir() bool
}

type Template

type Template interface {
	Source
	Info() TemplateInfo
	Name() string
}

type TemplateInfo

type TemplateInfo struct {
	Name        string `json:"name"`
	ShortName   string `json:"shortname"`
	Author      string `json:"author"`
	Description string `json:"description"`
	HelpUrl     string `json:"helpurl"`
}

type Type

type Type int
const (
	TypeAny     Type = 0
	TypeBackend Type = 1 << (iota - 1)
	TypeFrontend
	TypeDev
	TypeBundle
)

func ParseType

func ParseType(def Type, args ...string) (typ Type)

func (Type) Is

func (t Type) Is(p Type) bool

Jump to

Keyboard shortcuts

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