forked from lerenn/asyncapi-codegen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasyncapi.gen.go
77 lines (64 loc) · 2.5 KB
/
asyncapi.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
// Package "issue137" provides primitives to interact with the AsyncAPI specification.
//
// Code generated by github.com/lerenn/asyncapi-codegen version (devel) DO NOT EDIT.
package issue137
import (
"fmt"
"github.com/lerenn/asyncapi-codegen/pkg/extensions"
)
// AsyncAPIVersion is the version of the used AsyncAPI document
const AsyncAPIVersion = ""
// controller is the controller that will be used to communicate with the broker
// It will be used internally by AppController and UserController
type controller struct {
// broker is the broker controller that will be used to communicate
broker extensions.BrokerController
// subscriptions is a map of all subscriptions
subscriptions map[string]extensions.BrokerChannelSubscription
// logger is the logger that will be used² to log operations on controller
logger extensions.Logger
// middlewares are the middlewares that will be executed when sending or
// receiving messages
middlewares []extensions.Middleware
// handler to handle errors from consumers and middlewares
errorHandler extensions.ErrorHandler
}
// ControllerOption is the type of the options that can be passed
// when creating a new Controller
type ControllerOption func(controller *controller)
// WithLogger attaches a logger to the controller
func WithLogger(logger extensions.Logger) ControllerOption {
return func(controller *controller) {
controller.logger = logger
}
}
// WithMiddlewares attaches middlewares that will be executed when sending or receiving messages
func WithMiddlewares(middlewares ...extensions.Middleware) ControllerOption {
return func(controller *controller) {
controller.middlewares = middlewares
}
}
// WithErrorHandler attaches a errorhandler to handle errors from subscriber functions
func WithErrorHandler(handler extensions.ErrorHandler) ControllerOption {
return func(controller *controller) {
controller.errorHandler = handler
}
}
type MessageWithCorrelationID interface {
CorrelationID() string
SetCorrelationID(id string)
}
type Error struct {
Channel string
Err error
}
func (e *Error) Error() string {
return fmt.Sprintf("channel %q: err %v", e.Channel, e.Err)
}
// AuditSchema is a schema from the AsyncAPI specification required in messages
// Description: An audit event is a record of an event that has occurred in a system.
type AuditSchema struct {
Channel ChannelSchema `json:"channel" validate:"oneof=API0 API1 API2 API3 API4"`
}
// ChannelSchema is a schema from the AsyncAPI specification required in messages
type ChannelSchema string