/
oas_server_gen.go
88 lines (80 loc) · 3.29 KB
/
oas_server_gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Code generated by ogen, DO NOT EDIT.
package techempower
import (
"context"
"go.opentelemetry.io/otel/metric/instrument/syncint64"
"github.com/ogen-go/ogen/otelogen"
)
// Handler handles operations described by OpenAPI v3 specification.
type Handler interface {
// Caching implements Caching operation.
//
// Test #7. The Caching test exercises the preferred in-memory or separate-process caching technology
// for the platform or framework. For implementation simplicity, the requirements are very similar to
// the multiple database-query test Test #3, but use a separate database table. The requirements are
// quite generous, affording each framework fairly broad freedom to meet the requirements in the
// manner that best represents the canonical non-distributed caching approach for the framework.
// (Note: a distributed caching test type could be added later.).
//
// GET /cached-worlds
Caching(ctx context.Context, params CachingParams) (WorldObjects, error)
// DB implements DB operation.
//
// Test #2. The Single Database Query test exercises the framework's object-relational mapper (ORM),
// random number generator, database driver, and database connection pool.
//
// GET /db
DB(ctx context.Context) (WorldObject, error)
// JSON implements json operation.
//
// Test #1. The JSON Serialization test exercises the framework fundamentals including keep-alive
// support, request routing, request header parsing, object instantiation, JSON serialization,
// response header generation, and request count throughput.
//
// GET /json
JSON(ctx context.Context) (HelloWorld, error)
// Queries implements Queries operation.
//
// Test #3. The Multiple Database Queries test is a variation of Test #2 and also uses the World
// table. Multiple rows are fetched to more dramatically punish the database driver and connection
// pool. At the highest queries-per-request tested (20), this test demonstrates all frameworks'
// convergence toward zero requests-per-second as database activity increases.
//
// GET /queries
Queries(ctx context.Context, params QueriesParams) (WorldObjects, error)
// Updates implements Updates operation.
//
// Test #5. The Database Updates test is a variation of Test #3 that exercises the ORM's persistence
// of objects and the database driver's performance at running UPDATE statements or similar. The
// spirit of this test is to exercise a variable number of read-then-write style database operations.
//
// GET /updates
Updates(ctx context.Context, params UpdatesParams) (WorldObjects, error)
}
// Server implements http server based on OpenAPI v3 specification and
// calls Handler to handle requests.
type Server struct {
h Handler
cfg config
requests syncint64.Counter
errors syncint64.Counter
duration syncint64.Histogram
}
// NewServer creates new Server.
func NewServer(h Handler, opts ...Option) (*Server, error) {
s := &Server{
h: h,
cfg: newConfig(opts...),
}
var err error
if s.requests, err = s.cfg.Meter.SyncInt64().Counter(otelogen.ServerRequestCount); err != nil {
return nil, err
}
if s.errors, err = s.cfg.Meter.SyncInt64().Counter(otelogen.ServerErrorsCount); err != nil {
return nil, err
}
if s.duration, err = s.cfg.Meter.SyncInt64().Histogram(otelogen.ServerDuration); err != nil {
return nil, err
}
return s, nil
}