gateway

package
v0.0.29 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Settings Settings `yaml:"settings"`
	Rules    []Rule   `yaml:"rules"`
}

Config represents the top-level structure of the .devloop.yaml file.

type GatewayService

type GatewayService struct {
	pb.UnimplementedDevloopGatewayServiceServer // Embed for forward compatibility
	pb.UnimplementedGatewayClientServiceServer  // Embed for forward compatibility
	// contains filtered or unexported fields
}

GatewayService manages registered devloop instances and proxies requests.

func NewGatewayService

func NewGatewayService(orchestrator Orchestrator) *GatewayService

NewGatewayService creates a new GatewayService instance.

func (*GatewayService) Communicate

Communicate implements pb.DevloopGatewayServiceServer.

func (*GatewayService) GetConfig

GetConfig implements pb.GatewayClientServiceServer.

func (*GatewayService) GetHistoricalLogsClient

GetHistoricalLogsClient implements pb.GatewayClientServiceServer.

func (*GatewayService) GetRuleStatus

GetRuleStatus implements pb.GatewayClientServiceServer.

func (*GatewayService) ListWatchedPaths

ListWatchedPaths implements pb.GatewayClientServiceServer.

func (*GatewayService) ReadFileContent

ReadFileContent implements pb.GatewayClientServiceServer.

func (*GatewayService) Start

func (gs *GatewayService) Start(grpcPort int, httpPort int) error

func (*GatewayService) Stop

func (gs *GatewayService) Stop()

func (*GatewayService) StreamLogsClient

StreamLogsClient implements pb.GatewayClientServiceServer.

func (*GatewayService) TriggerRuleClient

TriggerRuleClient implements pb.GatewayClientServiceServer.

type Matcher

type Matcher struct {
	Action   string   `yaml:"action"` // Should be "include" or "exclude"
	Patterns []string `yaml:"patterns"`
}

Matcher defines a single include or exclude directive using glob patterns.

func (*Matcher) Matches

func (m *Matcher) Matches(filePath string) bool

type Orchestrator

type Orchestrator interface {
	GetConfig() *Config
	GetRuleStatus(ruleName string) (*RuleStatus, bool)
	TriggerRule(ruleName string) error
	GetWatchedPaths() []string
	ReadFileContent(path string) ([]byte, error)
	StreamLogs(ruleName string, filter string, stream pb.GatewayClientService_StreamLogsClientServer) error
}

Orchestrator is an interface that defines the methods that the gateway service needs to interact with the orchestrator.

type ProjectInstance

type ProjectInstance struct {
	ProjectID   string `json:"project_id"`
	ProjectRoot string `json:"project_root"`
	// contains filtered or unexported fields
}

ProjectInstance represents a registered devloop instance.

type Rule

type Rule struct {
	Name          string            `yaml:"name"`
	Prefix        string            `yaml:"prefix,omitempty"`
	Commands      []string          `yaml:"commands"`
	Watch         []*Matcher        `yaml:"watch"`
	Env           map[string]string `yaml:"env,omitempty"`
	WorkDir       string            `yaml:"workdir,omitempty"`
	RunOnInit     *bool             `yaml:"run_on_init,omitempty"`
	DebounceDelay *time.Duration    `yaml:"debounce_delay,omitempty"`
	Verbose       *bool             `yaml:"verbose,omitempty"`
	Color         string            `yaml:"color,omitempty"`
	DefaultAction string            `yaml:"default_action,omitempty"` // "include" or "exclude"
}

Rule defines a single watch-and-run rule.

func (*Rule) Matches

func (r *Rule) Matches(filePath string) *Matcher

Matches checks if the given file path matches the rule's watch criteria.

type RuleStatus

type RuleStatus struct {
	ProjectID       string    `json:"project_id"`
	RuleName        string    `json:"rule_name"`
	IsRunning       bool      `json:"is_running"`
	StartTime       time.Time `json:"start_time,omitempty"`
	LastBuildTime   time.Time `json:"last_build_time,omitempty"`
	LastBuildStatus string    `json:"last_build_status,omitempty"` // e.g., "SUCCESS", "FAILED", "IDLE"
}

RuleStatus defines the status of a rule.

type Settings

type Settings struct {
	ProjectID            string            `yaml:"project_id,omitempty"`
	PrefixLogs           bool              `yaml:"prefix_logs"`
	PrefixMaxLength      int               `yaml:"prefix_max_length"`
	DefaultDebounceDelay *time.Duration    `yaml:"default_debounce_delay,omitempty"`
	Verbose              bool              `yaml:"verbose,omitempty"`
	ColorLogs            bool              `yaml:"color_logs,omitempty"`
	ColorScheme          string            `yaml:"color_scheme,omitempty"`
	CustomColors         map[string]string `yaml:"custom_colors,omitempty"`
	DefaultWatchAction   string            `yaml:"default_watch_action,omitempty"` // "include" or "exclude"
}

Settings defines global settings for devloop.

Jump to

Keyboard shortcuts

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