bootstrap

package
v0.0.0-...-fb0c258 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package bootstrap 构造应用基础层:数据库连接、共享依赖(appkit.Deps)与 托管 grpcapi Server 的 lynx.Service。模块经 Deps 消费这一切。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HintDB

func HintDB(err error) string

HintDB 对最常见的本地连接失败形态(端口被既有 Postgres 占用→撞上别家 凭据)给出排障提示;migrate 与 server 启动共用。错误形态不匹配时返回空串。

func NewDeps

func NewDeps(app lynx.App, cfg *config.Config, logger *slog.Logger) (appkit.Deps, func(), error)

NewDeps 打开数据库并构造模块共享依赖;返回的 cleanup 关闭连接池 (main.go 挂 OnPostStop)。

Types

type APIService

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

APIService 把 grpcapi Server 托管进 lynx 生命周期:Start 阻塞运行 gRPC+HTTP 双面,Stop 触发优雅关停。

func NewAPIService

func NewAPIService(srv *grpcapiserver.Server, logger *slog.Logger) *APIService

NewAPIService 构造 APIService。

func (*APIService) Init

func (s *APIService) Init(_ lynx.AppContext) error

Init 实现 lynx.Service。

func (*APIService) Name

func (s *APIService) Name() string

Name 实现 lynx.Service。

func (*APIService) Start

func (s *APIService) Start(ctx context.Context) error

Start 实现 lynx.Service:Run 在 ctx 取消时返回。

func (*APIService) Stop

func (s *APIService) Stop(ctx context.Context) error

Stop 实现 lynx.Service:Run 返回后的 Shutdown 幂等安全。

Jump to

Keyboard shortcuts

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