api

package
v0.5.13 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0, MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(c *cli.Context) error

Types

type APIParams added in v0.3.0

type APIParams struct {
	Listener   net.Listener
	LotusAPI   string
	LotusToken string
	ConnString string
}

type HTTPError added in v0.3.0

type HTTPError struct {
	Err string `json:"err"`
}

type Server

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

func InitServer added in v0.3.0

func InitServer(ctx context.Context, params APIParams) (Server, error)

func (Server) Name added in v0.4.0

func (s Server) Name() string

func (Server) Start added in v0.4.0

func (s Server) Start(ctx context.Context, exitErr chan<- error) error

Start initializes the server, sets up routes and middlewares, and starts listening for incoming requests.

This method:

  • Initializes analytics.
  • Configures the echo server with recovery, logging, and CORS middleware.
  • Sets up various routes, including serving static files for the dashboard and a swagger UI.
  • Starts the echo server and manages its lifecycle with background goroutines.
  • Gracefully shuts down the server on context cancellation.
  • Closes database connections and other resources.

Parameters:

  • ctx: A context.Context used to control the server's lifecycle and propagate cancellation.

Returns:

  • A slice of channels (service.Done) that signal when different parts of the service have completed their work. This includes: 1. The main echo server's completion. 2. The host's completion. 3. Completion of analytics event flushing.
  • A channel (service.Fail) that reports errors that occur while the server is running.
  • An error if there is an issue during the initialization phase, otherwise nil.

Jump to

Keyboard shortcuts

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