gateway

package
v0.0.30 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: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertAirToml added in v0.0.30

func ConvertAirToml(inputPath string) error

Types

type AirConfig added in v0.0.30

type AirConfig struct {
	Root   string      `toml:"root"`
	TmpDir string      `toml:"tmp_dir"`
	Build  BuildConfig `toml:"build"`
	Log    LogConfig   `toml:"log"`
	Misc   MiscConfig  `toml:"misc"`
	Color  ColorConfig `toml:"color"`
}

AirConfig represents the structure of a .air.toml file.

type BuildConfig added in v0.0.30

type BuildConfig struct {
	Cmd          string   `toml:"cmd"`
	Bin          string   `toml:"bin"`
	PreCmd       []string `toml:"pre_cmd"`
	PostCmd      []string `toml:"post_cmd"`
	IncludeExt   []string `toml:"include_ext"`
	ExcludeDir   []string `toml:"exclude_dir"`
	ExcludeFile  []string `toml:"exclude_file"`
	IncludeDir   []string `toml:"include_dir"`
	ExcludeRegex []string `toml:"exclude_regex"`
	StopOnError  bool     `toml:"stop_on_error"`
	Delay        int      `toml:"delay"`
}

type ColorConfig added in v0.0.30

type ColorConfig struct {
	Main    string `toml:"main"`
	Watcher string `toml:"watcher"`
	Build   string `toml:"build"`
	Runner  string `toml:"runner"`
}

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 LogConfig added in v0.0.30

type LogConfig struct {
	LogName        string `toml:"log_name"`
	RedirectOutput bool   `toml:"redirect_output"`
}

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 MiscConfig added in v0.0.30

type MiscConfig struct {
	CleanOnExit bool `toml:"clean_on_exit"`
}

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) GetColor added in v0.0.30

func (r *Rule) GetColor() string

GetColor returns the rule color (implements ColorRule interface)

func (*Rule) GetName added in v0.0.30

func (r *Rule) GetName() string

GetName returns the rule name (implements Nameable interface for color generation)

func (*Rule) GetPrefix added in v0.0.30

func (r *Rule) GetPrefix() string

GetPrefix returns the rule prefix (implements ColorRule interface)

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.

func (*Settings) GetColorLogs added in v0.0.30

func (s *Settings) GetColorLogs() bool

GetColorLogs returns whether color logs are enabled (implements ColorSettings interface)

func (*Settings) GetColorScheme added in v0.0.30

func (s *Settings) GetColorScheme() string

GetColorScheme returns the color scheme (implements ColorSettings interface)

func (*Settings) GetCustomColors added in v0.0.30

func (s *Settings) GetCustomColors() map[string]string

GetCustomColors returns the custom color mappings (implements ColorSettings interface)

Jump to

Keyboard shortcuts

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