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 ¶
- func Serve(ctx context.Context, addr string, svc *Service, staticFS http.Handler) error
- type Service
- func (s *Service) AcquireFlowLock(ctx context.Context, req *platform.AcquireFlowLockRequest) (*platform.AcquireFlowLockResponse, error)
- func (s *Service) CreateFlow(ctx context.Context, req *platform.CreateFlowRequest) (*platform.Nil, error)
- func (s *Service) GetFlow(ctx context.Context, req *platform.GetFlowRequest) (*platform.GetFlowResponse, error)
- func (s *Service) GetFlowList(ctx context.Context, req *platform.GetFlowListRequest) (*platform.GetFlowListResponse, error)
- func (s *Service) GetFlowStream(req *platform.GetFlowStreamRequest, ...) error
- func (s *Service) ReleaseFlowLock(ctx context.Context, req *platform.ReleaseFlowLockRequest) (*platform.Nil, error)
- func (s *Service) ServeEditor(ctx context.Context, addr, activeProject string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Serve ¶
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 ¶
NewService binds the service to one cluster + namespace.
func (*Service) AcquireFlowLock ¶
func (s *Service) AcquireFlowLock(ctx context.Context, req *platform.AcquireFlowLockRequest) (*platform.AcquireFlowLockResponse, error)
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 ¶
func (s *Service) GetFlow(ctx context.Context, req *platform.GetFlowRequest) (*platform.GetFlowResponse, error)
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 ¶
func (s *Service) GetFlowList(ctx context.Context, req *platform.GetFlowListRequest) (*platform.GetFlowListResponse, error)
GetFlowList lists the project's flows (the layers) for the flow switcher.
func (*Service) GetFlowStream ¶
func (s *Service) GetFlowStream(req *platform.GetFlowStreamRequest, stream grpc.ServerStreamingServer[platform.GetFlowStreamResponse]) error
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 ¶
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.