server

package
v0.0.0-...-ef927d8 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 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) error

func WithClock

func WithClock(clock pulse.Clock) Option

WithClock sets the clock used by the server.

func WithFileReader

func WithFileReader(reader FileReader) Option

WithFileReader sets the file reader used by the server.

func WithLog

func WithLog(log *log.Logger) Option

WithLog sets the logger used by the server.

func WithStorage

func WithStorage(storage pulse.TemporaryStorage) Option

WithStorage sets the storage used by the server.

type Server

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

func New

func New(serverName string, opts ...Option) (*Server, error)

New creates a new server.

func (*Server) CheckHeartbeat

func (s *Server) CheckHeartbeat()

CheckHeartbeat is used to check if the session has been inactive for more than ten minutes. If that is the case, the session will be terminated and saved to disk.

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. It is used to set the editor that is currently active. Even though we might have multiple editors open at any given time, we'll only count time for one.

func (*Server) HeartbeatCheck

func (s *Server) HeartbeatCheck() func()

HeartbeatCheck runs a heartbeat ticker that ensures that the current session is not idle for more than ten minutes.

func (*Server) OpenFile

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

OpenFile gets invoked by the *BufEnter* autocommand.

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) Start

func (s *Server) Start(port string) error

Start starts the server on the given port.

Jump to

Keyboard shortcuts

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