Skip to content

Server Resource Handlers

lsp_utils.ServerStatus

A ServerStatus enum for use as a return value from ServerResourceInterface.get_status().

UNINITIALIZED class-attribute instance-attribute

UNINITIALIZED = 1

Initial status of the server.

ERROR class-attribute instance-attribute

ERROR = 2

Initiallation or update has failed.

READY class-attribute instance-attribute

READY = 3

Server is ready to provide resources.

lsp_utils.ServerResourceInterface

Bases: ABC

Interface for implementating server resource handlers.

Use this interface in plugins that manage their own server binary (GenericClientHandler.manages_server returns True).

After implementing this interface, return an instance of implemented class from GenericClientHandler.get_server().

binary_path abstractmethod property

binary_path: str

Filesystem path to the server binary.

needs_installation abstractmethod

needs_installation() -> bool

Check whether the binary needs an update, or whether it needs to be installed before starting server.

Returns:

Type Description
bool

True if the server needs to be installed or updated. This will result in calling install_or_update().

install_or_update abstractmethod

install_or_update() -> None

Do the actual update/installation of the server binary.

Don't start extra threads to do the work as everything is handled automatically.

get_status abstractmethod

get_status() -> int

Determine the current status of the server.

The state changes as the server is being installed, updated or runs into an error doing those. Initialize with ServerStatus.UNINITIALIZED and change to either Set to ServerStatus.ERROR or ServerStatus.READY depending on if the server was installed correctly or is already installed.

Returns:

Type Description
int

A number corresponding to the ServerStatus class members.