Documentation
¶
Index ¶
- func ReadMessage(r io.Reader, dst interface{}) error
- func WriteMessage(w io.Writer, msg interface{}) error
- type AttachPayload
- type DetachPayload
- type GatewayExposePayload
- type GatewayStatusPayload
- type GatewayUpPayload
- type ListResponsePayload
- type RemovePayload
- type Request
- type Response
- type ServiceInfo
- type StartPayload
- type StartResponsePayload
- type StopPayload
- type TargetStartPayload
- type TargetStopPayload
- type TunnelListPayload
- type TunnelStatusPayload
- type TunnelUpPayload
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadMessage ¶
ReadMessage reads a length-prefixed JSON message and decodes it into dst.
func WriteMessage ¶
WriteMessage encodes msg as JSON and writes it with a 4-byte big-endian length prefix.
Types ¶
type AttachPayload ¶
type AttachPayload struct {
Name string `json:"name"`
}
type DetachPayload ¶
type DetachPayload struct {
Name string `json:"name"`
}
type GatewayExposePayload ¶ added in v0.5.0
GatewayExposePayload adds or removes services from the allowlist — what may leave this machine.
type GatewayStatusPayload ¶ added in v0.5.0
type GatewayStatusPayload struct {
Running bool `json:"running"`
Addr string `json:"addr,omitempty"`
Posture string `json:"posture,omitempty"`
Mode string `json:"mode,omitempty"`
Token string `json:"token,omitempty"`
Exposed []string `json:"exposed,omitempty"`
PID *int `json:"pid,omitempty"`
// PublicHostname is the gateway's {service} template, so a caller can
// build each service's address without knowing how the gateway resolves
// one. Empty means services are addressed by path.
PublicHostname string `json:"public_hostname,omitempty"`
// Tunnel is nil when nothing devrun manages is publishing this gateway.
// Nil does not mean unpublished: someone may be fronting it with ngrok or
// a Caddy devrun knows nothing about, which is what posture reports.
Tunnel *TunnelStatusPayload `json:"tunnel,omitempty"`
}
GatewayStatusPayload is the gateway's runtime state. A zero value means it is not running.
type GatewayUpPayload ¶ added in v0.5.0
type GatewayUpPayload struct {
Config *config.GatewayConfig `json:"config,omitempty"`
}
GatewayUpPayload starts (or reconfigures) the gateway. The config travels inline for the same reason a project service's does: the daemon cannot read the devrun.yaml the CLI resolved.
type ListResponsePayload ¶
type ListResponsePayload struct {
Services []ServiceInfo `json:"services"`
// Gateway is nil when it is not running, so every caller reads the same
// answer rather than each deciding what absence means.
Gateway *GatewayStatusPayload `json:"gateway,omitempty"`
// ActiveTargets names the targets the daemon currently considers started,
// sorted. Empty when no target has been started.
ActiveTargets []string `json:"active_targets,omitempty"`
}
type RemovePayload ¶
type RemovePayload struct {
Name string `json:"name"`
}
type Request ¶
type Request struct {
Type string `json:"type"`
Payload json.RawMessage `json:"payload"`
}
Request is the envelope for all CLI→daemon requests.
type Response ¶
type Response struct {
OK bool `json:"ok"`
Payload json.RawMessage `json:"payload,omitempty"`
Error string `json:"error,omitempty"`
EOF bool `json:"eof,omitempty"`
}
Response is the envelope for all daemon→CLI responses.
type ServiceInfo ¶
type ServiceInfo struct {
Name string `json:"name"`
Group string `json:"group"`
State string `json:"state"`
PID *int `json:"pid"`
Port *int `json:"port"`
UptimeSec int64 `json:"uptime_s"`
CPUPct float64 `json:"cpu_pct"`
MemBytes int64 `json:"mem_bytes"`
// URL is where this service can be opened from this machine, when the
// gateway is up and serving it. Empty otherwise — a service with no port,
// or one withheld while published, has no address to give out. A running
// tunnel makes the gateway withhold from local requests too, so starting
// one empties this for every service not on the allowlist.
URL string `json:"url,omitempty"`
// PublicURL is where the same service can be opened from anywhere, and is
// set only for an exposed service under a devrun-managed tunnel. It sits
// beside URL rather than replacing it: both work, and the local one is
// the one being developed against.
PublicURL string `json:"public_url,omitempty"`
}
type StartPayload ¶
type StartPayload struct {
Name string `json:"name"`
Config *config.ServiceConfig `json:"config,omitempty"`
}
StartPayload names the service to start. Config, when set, carries the full service definition inline (used for project devrun.yaml services that are not in the global registry); when nil the daemon resolves Name from the registry.
type StartResponsePayload ¶
type StartResponsePayload struct {
PID int `json:"pid"`
}
type StopPayload ¶
type StopPayload struct {
Name string `json:"name"`
}
type TargetStartPayload ¶
type TargetStartPayload struct {
Name string `json:"name"`
Services []*config.ServiceConfig `json:"services"`
}
TargetStartPayload starts every service in a target. Services carries the full definitions inline — the daemon has no target vocabulary of its own — the same way project devrun.yaml services are shipped in StartPayload.
type TargetStopPayload ¶
type TargetStopPayload struct {
Name string `json:"name"`
}
TargetStopPayload stops a target. The daemon resolves which members to stop from the snapshot it recorded at target-start time, skipping any still held by another active target.
type TunnelListPayload ¶ added in v0.5.0
TunnelListPayload carries the account's tunnel names. Known is false when cloudflared could not be asked — no login, no network — which callers must not read as "the name does not exist".
type TunnelStatusPayload ¶ added in v0.5.0
type TunnelStatusPayload struct {
Running bool `json:"running"`
Kind string `json:"kind,omitempty"` // "named" | "quick"
Name string `json:"name,omitempty"`
// PublicURL may be empty for a running quick tunnel whose banner could not
// be read. The tunnel works; devrun just cannot print the address.
PublicURL string `json:"public_url,omitempty"`
PID *int `json:"cloudflared_pid,omitempty"`
}
TunnelStatusPayload is the tunnel's runtime state. A zero value means devrun is not running one.
type TunnelUpPayload ¶ added in v0.5.0
type TunnelUpPayload struct {
Config *config.TunnelConfig `json:"config,omitempty"`
Gateway *config.GatewayConfig `json:"gateway,omitempty"`
// Expose names services that may leave this machine, added to the
// allowlist before anything is published.
Expose []string `json:"expose,omitempty"`
}
TunnelUpPayload starts the tunnel, and the gateway under it if needed. Both configs travel inline, as a project service's does: the daemon cannot read the devrun.yaml the CLI resolved. By the time this is sent the CLI has already resolved flags, config and any prompt into a complete TunnelConfig.