{"modulePath":"github.com/newstack-cloud/ls-builder","version":"v0.2.5","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package server\n\n## Variables\n\n```go\nvar DefaultTimeout = time.Minute\n```\nDefaultTimeout is the default timeout used for a JSON-RPC 2.0 connection.\n\n## Functions\n\n```go\nfunc CreateConnectionOptions(debug bool, logger *zap.Logger) []jsonrpc2.ConnOpt\n```\n\n```go\nfunc NewLSPContext(ctx context.Context, conn *jsonrpc2.Conn, request *jsonrpc2.Request) *common.LSPContext\n```\nNewLSPContext creates a new LSP context from the given connection and request.\n\n```go\nfunc NewStreamConnection(handler jsonrpc2.Handler, stream io.ReadWriteCloser, opts ...ConnOption) *jsonrpc2.Conn\n```\nNewStreamConnection creates a new JSON-RPC 2.0 connection over a stream (io.ReadWriterCloser).\n\n```go\nfunc NewWebSocketConnection(handler jsonrpc2.Handler, wsConn *websocket.Conn, opts ...ConnOption) *jsonrpc2.Conn\n```\nNewWebSocketConnection creates a new JSON-RPC 2.0 connection over a WebSocket connection.\n\n```go\nfunc RunTCP(ctx context.Context, address string, server *Server, logger *zap.Logger) error\n```\nRunTCP begins listening for TCP connections on the provided address, creating a LSP over JSON-RPC 2.0 connection on top of each incoming TCP connection with the provided server.\n\n```go\nfunc RunWebSocketServer(address string, server *Server, logger *zap.Logger, httpServer *http.Server) error\n```\nRunWebSocketServer starts a new web socket server on the provided address.\n\n## Types\n\n```go\ntype ConnOption func(*connWrapper)\n```\nConnOption is a function that configures a connection.\n\n```go\nfunc WithJSONRPCConnOptions(opts ...jsonrpc2.ConnOpt) ConnOption\n```\nWithJSONRPCConnOptions configures the connection with JSON-RPC 2.0 connection options.\n\n```go\nfunc WithReadTimeout(timeout time.Duration) ConnOption\n```\nWithReadTimeout configures the connection with a read timeout.\n\n```go\nfunc WithTimeout(timeout time.Duration) ConnOption\n```\nWithTimeout configures the connection with a timeout.\n\n```go\nfunc WithWebSocket(wsConn *websocket.Conn) ConnOption\n```\nWithWebSocket configures the connection with a WebSocket connection.\n\n```go\nfunc WithWriteTimeout(timeout time.Duration) ConnOption\n```\nWithWriteTimeout configures the connection with a write timeout.\n\n```go\ntype JSONRPCLogger struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (l *JSONRPCLogger) Printf(format string, v ...any)\n```\nPrintf implements the jsonrpc2.Logger interface.\n\n```go\ntype Server struct {\n\t// contains filtered or unexported fields\n}\n```\nServer is an LSP over JSON-RPC 2.0 server that works for all versions of LSP that ls-builder provides.\n\n```go\nfunc NewServer(\n\thandler common.Handler,\n\tdebug bool,\n\tlogger *zap.Logger,\n\tconn *jsonrpc2.Conn,\n\topts ...ServerOption,\n) *Server\n```\nNewServer creates a new LSP server over JSON-RPC 2.0.\n\n```go\nfunc (s *Server) GetReadTimeout() time.Duration\n```\nGetReadTimeout returns the server's read timeout.\n\n```go\nfunc (s *Server) GetTimeout() time.Duration\n```\nGetTimeout returns the server's timeout.\n\n```go\nfunc (s *Server) GetWriteTimeout() time.Duration\n```\nGetWriteTimeout returns the server's write timeout.\n\n```go\nfunc (s *Server) NewHandler() jsonrpc2.Handler\n```\nNewHandler creates a handler from the server to handle JSON-RPC requests.\n\n```go\nfunc (s *Server) Serve(optConn *jsonrpc2.Conn, connLogger *zap.Logger)\n```\nServe serves a JSON-RPC 2.0 connection. If nil is passed in for the connection, the server will use the connection that was configured when the server was created.\n\n```go\nfunc (s *Server) ServeWebSocket(conn *websocket.Conn, logger *zap.Logger)\n```\nServeWebSocket serves a JSON-RPC 2.0 connection over a WebSocket connection. See \\`RunWebSocketServer\\` for a complete example of how to serve JSON-RPC 2.0 communication over WebSockets.\n\n```go\ntype ServerOption func(*Server)\n```\nServerOption is a function that configures a server.\n\n```go\nfunc WithServerReadTimeout(timeout time.Duration) ServerOption\n```\nWithServerReadTimeout configures the server with a read timeout.\n\n```go\nfunc WithServerTimeout(timeout time.Duration) ServerOption\n```\nWithServerTimeout configures the server with a timeout.\n\n```go\nfunc WithServerWriteTimeout(timeout time.Duration) ServerOption\n```\nWithServerWriteTimeout configures the server with a write timeout.\n\n```go\ntype Stdio struct{}\n```\nStdio provides a ReadWriteCloser interface to os.Stdin and os.Stdout to be used as the transport layer for a language server over JSON-RPC 2.0.\n\n```go\nfunc (Stdio) Close() error\n```\nClose closes os.Stdin and os.Stdout. Fulfils the io.Closer interface.\n\n```go\nfunc (Stdio) Read(p []byte) (int, error)\n```\nRead reads from os.Stdin. Fulfils the io.Reader interface.\n\n```go\nfunc (Stdio) Write(p []byte) (int, error)\n```\nWrite writes to os.Stdout. Fulfils the io.Writer interface.\n\n","path":"github.com/newstack-cloud/ls-builder/server","name":"server","synopsis":"","isRedistributable":true}
