来源信息
- 仓库
- zalando/skipper
- 最近来源活动
- 2026年8月31日 10:11
- 检测到的 SKILL.md 语言
- 英语
- 星标
- 3,331
- Forks
- 409
安装方式
默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。
检查来源文件
决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。
正在显示 SKILL.md
SKILL.md
来源说明 · 只读预览- name
- predicate
- description
- Create or modify code in the predicates package and all its sub-folders
- license
- MIT
- compatibility
- opencode, claude
- metadata
- {"audience":"maintainers, contributors"}
## What I do
- Create predicate code that is efficient and readable
## When to use me
Use this when you are writing code in sub-folders of
./predicates/. Some predicates are also located in the ./routing/
folder for historical reasons.
## Quick start
A predicate consists of 2 types `spec` and `predicate` that implement 2 different interfaces:
```go
// PredicateSpec instances are used to create custom predicates
// (of type Predicate) with concrete arguments during the
// construction of the routing tree.
type PredicateSpec interface {
// Name of the predicate as used in the route definitions.
Name() string
// Creates a predicate instance with concrete arguments.
Create([]any) (Predicate, error)
}
```
```go
// Predicate instances are used as custom user defined route
// matching predicates.
type Predicate interface {
// Returns true if the request matches the predicate.
Match(*http.Request) bool
}
```
The `Create([]any) (Predicate, error)` function is run at routing tree
creation time, so only once in a while. Everything we can pre-compute
to run a faster `Match(*http.Request) bool` execution the better. Here
we process input from developers or operators that might do
mistakes. We want to show errors clearly.
The `Predicate` interface function `Match(*http.Request) bool` is
running in the hotpath of the request processing. Here we need to be
very efficient and want to reduce latency, increase throughput,
minimize allocations and we run heavily concurrent. Every request will
be proceesed by a lot of `Predicates` and so each `Match` needs to be
as fast as possible.
在 GitHub 查看