server

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeartbeatTTL = time.Minute * 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type FileReader

type FileReader interface {
	GitFile(path string) (pulse.GitFile, error)
}

FileReader is a simple abstraction that defines a function for getting metadata from a file within a git repository.

type Option

type Option func(*Server)

func WithClock

func WithClock(clock clock.Clock) Option

WithClock sets the clock used by the server.

func WithLog

func WithLog(log *log.Logger) Option

WithLog sets the logger used by the server.

type Proxy

type Proxy struct {
	// contains filtered or unexported fields
}

Proxy serves as the intermediary between our client and server. It directs remote procedure calls to the server, mitigating the risk of unintentionally revealing server methods, just because they happen to conform to the RPC interface.

func NewProxy

func NewProxy(server *Server) *Proxy

New returns a new proxy.

func (*Proxy) EndSession

func (p *Proxy) EndSession(event pulse.Event, reply *string) error

EndSession should be called when the neovim process ends.

func (*Proxy) FocusGained

func (p *Proxy) FocusGained(event pulse.Event, reply *string) error

FocusGained should be called when a buffer gains focus.

func (*Proxy) OpenFile

func (p *Proxy) OpenFile(event pulse.Event, reply *string) error

OpenFile should be called when a buffer is opened. The server will check if the path is a valid file.

func (*Proxy) SendHeartbeat

func (p *Proxy) SendHeartbeat(event pulse.Event, reply *string) error

SendHeartbeat can be called for events such as buffer writes and cursor moves. Its purpose is to notify the server that the current session remains active. If we don't perform any actions for 10 minutes the server is going to end the session.

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(cfg *pulse.Config, segmentPath string, sessionWriter SessionWriter, opts ...Option) *Server

New creates a new server.

func (*Server) EndSession

func (s *Server) EndSession(event pulse.Event, reply *string)

EndSession should be called by the *VimLeave* autocommand.

func (*Server) FocusGained

func (s *Server) FocusGained(event pulse.Event, reply *string)

FocusGained is invoked by the FocusGained autocommand.

func (*Server) OpenFile

func (s *Server) OpenFile(event pulse.Event, reply *string)

OpenFile gets invoked by the *BufEnter* autocommand.

func (*Server) RunBackgroundJobs

func (s *Server) RunBackgroundJobs(ctx context.Context, segmentationInterval time.Duration)

RunBackgroundJobs starts the heartbeat, aggregation, and segmentation jobs.

func (*Server) SendHeartbeat

func (s *Server) SendHeartbeat(event pulse.Event, reply *string)

SendHeartbeat can be called for events such as buffer writes and cursor moves. Its purpose is to notify the server that the current session remains active. The server ends the session if it doesn't receive a heartbeat for 10 minutes.

func (*Server) StartServer

func (s *Server) StartServer(ctx context.Context, port string) error

Start starts the server on the given port.

type SessionWriter

type SessionWriter interface {
	Write(context.Context, pulse.CodingSession) error
}

Jump to

Keyboard shortcuts

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