Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeGetEndpoint ¶
MakeGetEndpoint 返回 「get」服务的响应
func MakeStatusEndpoint ¶
MakeStatusEndpoint 返回 「status」服务的响应
func MakeValidateEndpoint ¶
MakeValidateEndpoint 返回「validate」服务的响应
Types ¶
type Endpoints ¶
type Endpoints struct { GetEndpoint endpoint.Endpoint // Get方法的端点 StatusEndpoint endpoint.Endpoint // Status方法的端点 ValidateEndpoint endpoint.Endpoint // Validate方法的端点 }
Endpoints 公开端点
type Service ¶
type Service interface { Status(ctx context.Context) (string, error) // 状态 Get(ctx context.Context) (string, error) // 获取 Validate(ctx context.Context, date string) (bool, error) // 校验 }
Service 服务为您的应用程序提供了一些「日期功能」 在这里,我们为服务定义了「蓝图」:在 Go kit 中,您必须将服务建模为接口 如上所述,我们将需要三个端点,这些端点将被映射到此接口。 为什么我们要使用 context 包?请阅读 https://blog.golang.org/context 在 Google,我们开发了一个上下文包,可轻松将跨 API 边界的请求范围的值,取消信号和截止日期传递给处理请求的所有协程 基本上,这是必需的,因为我们的微服务应该从一开始就处理并发请求,并且必须为每个请求提供上下文。 不要把事情搞混。本教程后面的内容将对此进行详细介绍。我们现在用的不多,但要习惯它! 现在我们有了微服务接口。
Click to show internal directories.
Click to hide internal directories.