Skip to content

refactor: move lava contracts to pkg/lava (#118)#145

Merged
kooksee merged 1 commit into
v2from
refactor/lava-pkg-boundary
Jul 5, 2026
Merged

refactor: move lava contracts to pkg/lava (#118)#145
kooksee merged 1 commit into
v2from
refactor/lava-pkg-boundary

Conversation

@kooksee

@kooksee kooksee commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Move Request/Response/Middleware/router interfaces from module root lava/ to pkg/lava/.
  • Update all internal imports to github.com/pubgo/lava/v2/pkg/lava.
  • Keep root lava/ as a deprecated type-alias shim for external backward compatibility.

Closes #118

Notes

  • pkg/lava/router.go still references fiber/gRPC types; further decoupling can be a follow-up.

Test plan

  • go test ./... -race -short
  • golangci-lint run ./lava/... ./pkg/lava/...

Made with Cursor

Relocate Request/Middleware/Router interfaces to pkg/lava and point internal imports at the new path; keep root lava/ as a deprecated re-export shim.

Co-authored-by: Cursor <cursoragent@cursor.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request moves the core contracts and interfaces of the lava package to a new location under pkg/lava, updating all internal import paths accordingly. To maintain backward compatibility, a deprecated lava package is introduced in lava/doc.go that re-exports the public API. Feedback was provided to avoid re-exporting package-level functions as mutable variables (var) in lava/doc.go, suggesting instead to use wrapper functions to prevent accidental or malicious overwrites.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread lava/doc.go
Comment on lines +34 to +37
var (
WithMiddleware = plava.WithMiddleware
Chain = plava.Chain
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Re-exporting package-level functions as mutable variables (var) allows external code or dependencies to accidentally or maliciously overwrite them (e.g., lava.Chain = nil). To prevent this and ensure safety, it is highly recommended to re-export them as wrapper functions instead.

Suggested change
var (
WithMiddleware = plava.WithMiddleware
Chain = plava.Chain
)
func WithMiddleware(name string, next func(next HandlerFunc) HandlerFunc) MiddlewareWrap {
return plava.WithMiddleware(name, next)
}
func Chain(middlewares ...Middleware) Middleware {
return plava.Chain(middlewares...)
}

@kooksee kooksee merged commit 2c2c547 into v2 Jul 5, 2026
2 checks passed
@kooksee kooksee deleted the refactor/lava-pkg-boundary branch July 5, 2026 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

architecture: lava 接口层位于模块根目录,边界模糊

1 participant