flow

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package flow is tiny's local implementation of the platform FlowService — the gRPC/gRPC-web API the browser editor talks to. It's backed by the cluster's TinyFlow/TinyNode CRDs (via the SDK's resource.Manager) and the shared SDK graph helpers (module/pkg/utils, module/pkg/schema), the same code the hosted platform calls. Only the RPCs the local editor needs are implemented; everything else falls through to UnimplementedFlowServiceServer (platform-only features — LLM prompt, revision history, registry browse).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(ctx context.Context, addr string, svc *Service, staticFS http.Handler) error

Serve runs the FlowService as a gRPC-web endpoint on addr (e.g. "127.0.0.1:7775") until ctx is cancelled. The editor's Connect-ES createGrpcWebTransport client talks to it directly — same wire protocol the hosted platform serves — with CORS opened for the localhost browser.

staticFS, when non-nil, serves the editor SPA for any non-gRPC request (that's Slice 3; nil for now leaves the endpoint gRPC-web-only).

Types

type Service

type Service struct {
	platform.UnimplementedFlowServiceServer
	// contains filtered or unexported fields
}

Service implements platform.FlowServiceServer against a local cluster.

func NewService

func NewService(cfg *rest.Config, namespace string) *Service

NewService binds the service to one cluster + namespace.

func (*Service) AcquireFlowLock

AcquireFlowLock always grants the lock: a single-user local editor has no contention, and the frontend gates editable rendering on this response.

func (*Service) CreateFlow

func (s *Service) CreateFlow(ctx context.Context, req *platform.CreateFlowRequest) (*platform.Nil, error)

CreateFlow adds a new flow (layer) to the project.

func (*Service) GetFlow

GetFlow returns flow metadata from the TinyFlow CR. The graph itself is streamed by GetFlowStream — the editor reads only ID/ResourceName/Meta here.

func (*Service) GetFlowList

GetFlowList lists the project's flows (the layers) for the flow switcher.

func (*Service) GetFlowStream

GetFlowStream is the render path: it streams the flow's nodes and edges to the canvas, then keeps the graph live as the cluster changes.

This is a stripped buildGraphEvents — the hosted platform overlays otel stats, redis logs, revision notices, and lock state onto the same stream; all of those degrade gracefully, so locally we ship just the graph: WatchNodes → SDK graph maps → node/edge upserts (ADDED/MODIFIED), delete events for elements that disappear, and a 2s heartbeat. The heavy work — schema overlay and edge validation — is the SDK's, identical to the platform.

func (*Service) ReleaseFlowLock

func (s *Service) ReleaseFlowLock(ctx context.Context, req *platform.ReleaseFlowLockRequest) (*platform.Nil, error)

ReleaseFlowLock is a no-op locally.

func (*Service) ServeEditor

func (s *Service) ServeEditor(ctx context.Context, addr, activeProject string) error

ServeEditor serves the browser editor on addr (e.g. "127.0.0.1:7775"): a small JSON API over the local cluster + the embedded single-page UI. This is the first live editor — a project picker, a flow (layer) switcher, and a canvas that renders the active flow's nodes and edges, polled from the cluster. The full gRPC-web FlowService (Serve) backs the richer canvas next.

Jump to

Keyboard shortcuts

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