Documentation ¶
Index ¶
- type ConsumeMessage
- type ConsumeMessageAck
- type Context
- func (c *Context) Abort()
- func (c *Context) AbortWithError(err error) *Error
- func (c *Context) Ack()
- func (c *Context) BindJSON(obj interface{}) error
- func (c *Context) BindProtoBuf(obj interface{}) error
- func (c *Context) BindXML(obj interface{}) error
- func (c *Context) BindYAML(obj interface{}) error
- func (c *Context) ConsumeMessage() *ConsumeMessage
- func (c *Context) Context() context.Context
- func (c *Context) Copy() *Context
- func (c *Context) Error(err error) *Error
- func (c *Context) Get(key string) (value interface{}, exists bool)
- func (c *Context) GetBool(key string) (b bool)
- func (c *Context) GetDuration(key string) (d time.Duration)
- func (c *Context) GetFloat64(key string) (f64 float64)
- func (c *Context) GetInt(key string) (i int)
- func (c *Context) GetInt64(key string) (i64 int64)
- func (c *Context) GetString(key string) (s string)
- func (c *Context) GetStringMap(key string) (sm map[string]interface{})
- func (c *Context) GetStringMapString(key string) (sms map[string]string)
- func (c *Context) GetStringMapStringSlice(key string) (smss map[string][]string)
- func (c *Context) GetStringSlice(key string) (ss []string)
- func (c *Context) GetTime(key string) (t time.Time)
- func (c *Context) Handler() HandlerFunc
- func (c *Context) HandlerName() string
- func (c *Context) HandlerNames() []string
- func (c *Context) IsAborted() bool
- func (c *Context) IsAck() bool
- func (c *Context) MustBindWith(obj interface{}, b binding.Binding) error
- func (c *Context) MustGet(key string) interface{}
- func (c *Context) Next()
- func (c *Context) Set(key string, value interface{})
- func (c *Context) ShouldBindJSON(obj interface{}) error
- func (c *Context) ShouldBindWith(obj interface{}, b binding.Binding) error
- func (c *Context) ShouldBindXML(obj interface{}) error
- func (c *Context) ShouldBindYAML(obj interface{}) error
- func (c *Context) Topic() string
- type Error
- type ErrorType
- type H
- type HandlerFunc
- type HandlersChain
- type MQClient
- type MQClientOptions
- type Option
- type Publisher
- func (p *Publisher) PublishDelayMessage(ctx context.Context, topicName, messageBody string, delay time.Duration) error
- func (p *Publisher) PublishDelayMessageProt(ctx context.Context, topicName, messageBody string, ...) error
- func (p *Publisher) PublishDelayMsgWithKeyTag(ctx context.Context, topicName, messageBody, messageTag, messageKey string, ...) error
- func (p *Publisher) PublishDelayMsgWithTag(ctx context.Context, topicName, messageBody, messageTag string, ...) error
- func (p *Publisher) PublishMessage(ctx context.Context, topicName, messageBody string) error
- func (p *Publisher) PublishMessageProp(ctx context.Context, topicName, messageTag, messageBody string, ...) error
- func (p *Publisher) PublishMsgWithKeyTag(ctx context.Context, topicName, messageBody, messageTag, messageKey string) error
- func (p *Publisher) PublishMsgWithTag(ctx context.Context, topicName, messageBody, messageTag string) error
- func (p *Publisher) TraceWithSpanContext(spCtx opentracing.SpanContext) *TracePublisher
- type PublisherOption
- type SubscribeEngine
- type SubscribeEngineOption
- type SubscribeOption
- func WithSubscribeConcurrency(curr int) SubscribeOption
- func WithSubscribeGroupID(groupID string) SubscribeOption
- func WithSubscribeHandlersChain(handlers ...HandlerFunc) SubscribeOption
- func WithSubscribeMaxWait(maxWait int) SubscribeOption
- func WithSubscribeMessageNum(messageNum int) SubscribeOption
- func WithSubscribeMessageTag(messageTag string) SubscribeOption
- func WithSubscribeTopicName(topicName string) SubscribeOption
- type Subscriber
- type TracePublisher
- type TraceSubscriber
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConsumeMessage ¶
type ConsumeMessage struct {
Messages mq_http_sdk.ConsumeMessageEntry
}
type ConsumeMessageAck ¶
type ConsumeMessageAck struct {
ReceiptHandle string
}
type Context ¶
type Context struct { // Keys is a key/value pair exclusively for the context of each request. Keys map[string]interface{} // Errors is a list of errors attached to all the handlers/middlewares who used this context. Errors errorMsgs // contains filtered or unexported fields }
Context is the most important part of gin. It allows us to pass variables between middleware, manage the flow, validate the JSON of a request and render a JSON response for example.
func (*Context) Abort ¶
func (c *Context) Abort()
Abort prevents pending handlers from being called. Note that this will not stop the current handler. Let's say you have an authorization middleware that validates that the current request is authorized. If the authorization fails (ex: the password does not match), call Abort to ensure the remaining handlers for this request are not called.
func (*Context) AbortWithError ¶
AbortWithError calls `AbortWithStatus()` and `Error()` internally. This method stops the chain, writes the status code and pushes the specified error to `c.Errors`. See Context.Error() for more details.
func (*Context) BindProtoBuf ¶
BindQuery is a shortcut for c.MustBindWith(obj, binding.Query).
func (*Context) ConsumeMessage ¶
func (c *Context) ConsumeMessage() *ConsumeMessage
Get returns the value for the given key, ie: (value, true). If the value does not exists it returns (nil, false)
func (*Context) Copy ¶
Copy returns a copy of the current context that can be safely used outside the request's scope. This has to be used when the context has to be passed to a goroutine.
func (*Context) Error ¶
Error attaches an error to the current context. The error is pushed to a list of errors. It's a good idea to call Error for each error that occurred during the resolution of a request. A middleware can be used to collect all the errors and push them to a database together, print a log, or append it in the HTTP response. Error will panic if err is nil.
func (*Context) Get ¶
Get returns the value for the given key, ie: (value, true). If the value does not exists it returns (nil, false)
func (*Context) GetDuration ¶
GetDuration returns the value associated with the key as a duration.
func (*Context) GetFloat64 ¶
GetFloat64 returns the value associated with the key as a float64.
func (*Context) GetStringMap ¶
GetStringMap returns the value associated with the key as a map of interfaces.
func (*Context) GetStringMapString ¶
GetStringMapString returns the value associated with the key as a map of strings.
func (*Context) GetStringMapStringSlice ¶
GetStringMapStringSlice returns the value associated with the key as a map to a slice of strings.
func (*Context) GetStringSlice ¶
GetStringSlice returns the value associated with the key as a slice of strings.
func (*Context) HandlerName ¶
HandlerName returns the main handler's name. For example if the handler is "handleGetUsers()", this function will return "main.handleGetUsers".
func (*Context) HandlerNames ¶
HandlerNames returns a list of all registered handlers for this context in descending order, following the semantics of HandlerName()
func (*Context) MustBindWith ¶
MustBindWith binds the passed struct pointer using the specified binding engine. It will abort the request with HTTP 400 if any error occurs. See the binding package.
func (*Context) MustGet ¶
MustGet returns the value for the given key if it exists, otherwise it panics.
func (*Context) Next ¶
func (c *Context) Next()
Next should be used only inside middleware. It executes the pending handlers in the chain inside the calling handler. See example in GitHub.
func (*Context) Set ¶
Set is used to store a new key/value pair exclusively for this context. It also lazy initializes c.Keys if it was not used previously.
func (*Context) ShouldBindJSON ¶
ShouldBindJSON is a shortcut for c.ShouldBindWith(obj, binding.JSON).
func (*Context) ShouldBindWith ¶
ShouldBindWith binds the passed struct pointer using the specified binding engine. See the binding package.
func (*Context) ShouldBindXML ¶
ShouldBindXML is a shortcut for c.ShouldBindWith(obj, binding.XML).
func (*Context) ShouldBindYAML ¶
ShouldBindYAML is a shortcut for c.ShouldBindWith(obj, binding.YAML).
type Error ¶
Error represents a error's specification.
func (*Error) MarshalJSON ¶
MarshalJSON implements the json.Marshaller interface.
type ErrorType ¶
type ErrorType uint64
ErrorType is an unsigned 64-bit error code as defined in the gin spec.
const ( // ErrorTypeBind is used when Context.Bind() fails. ErrorTypeBind ErrorType = 1 << 63 // ErrorTypeRender is used when Context.Render() fails. ErrorTypeRender ErrorType = 1 << 62 // ErrorTypePrivate indicates a private error. ErrorTypePrivate ErrorType = 1 << 0 // ErrorTypePublic indicates a public error. ErrorTypePublic ErrorType = 1 << 1 // ErrorTypeAny indicates any other error. ErrorTypeAny ErrorType = 1<<64 - 1 // ErrorTypeNu indicates any other error. ErrorTypeNu = 2 )
type HandlerFunc ¶
type HandlerFunc func(*Context)
HandlerFunc defines the handler used by rocketmq middleware as return value.
type HandlersChain ¶
type HandlersChain []HandlerFunc
HandlersChain defines a HandlerFunc array.
func (HandlersChain) Last ¶
func (c HandlersChain) Last() HandlerFunc
Last returns the last handler in the chain. ie. the last handler is the main one.
type MQClient ¶
type MQClient struct {
// contains filtered or unexported fields
}
func NewMQClient ¶
func (*MQClient) Consumer ¶
func (mc *MQClient) Consumer(topicName string, groupID string, messageTag string) mq_http_sdk.MQConsumer
func (*MQClient) Producer ¶
func (mc *MQClient) Producer(topicName string) mq_http_sdk.MQProducer
type MQClientOptions ¶
type MQClientOptions struct{}
func (MQClientOptions) WithLogger ¶
func (MQClientOptions) WithLogger(logger log.Logger) Option
type Publisher ¶
type Publisher struct {
// contains filtered or unexported fields
}
func NewPublisher ¶
func NewPublisher(options ...PublisherOption) *Publisher
func (*Publisher) PublishDelayMessage ¶
func (*Publisher) PublishDelayMessageProt ¶
func (*Publisher) PublishDelayMsgWithKeyTag ¶
func (*Publisher) PublishDelayMsgWithTag ¶
func (*Publisher) PublishMessage ¶
func (*Publisher) PublishMessageProp ¶
func (*Publisher) PublishMsgWithKeyTag ¶
func (p *Publisher) PublishMsgWithKeyTag(ctx context.Context, topicName, messageBody, messageTag, messageKey string) error
with message tag
func (*Publisher) PublishMsgWithTag ¶
func (p *Publisher) PublishMsgWithTag(ctx context.Context, topicName, messageBody, messageTag string) error
with message tag and key
func (*Publisher) TraceWithSpanContext ¶
func (p *Publisher) TraceWithSpanContext(spCtx opentracing.SpanContext) *TracePublisher
type PublisherOption ¶
type PublisherOption func(*Publisher)
func WithPublisherConf ¶
func WithPublisherConf(conf config.Config) PublisherOption
func WithPublisherLogger ¶
func WithPublisherLogger(logger log.Logger) PublisherOption
type SubscribeEngine ¶
type SubscribeEngine struct {
// contains filtered or unexported fields
}
func NewSubscribeEngine ¶
func NewSubscribeEngine(options ...SubscribeEngineOption) *SubscribeEngine
func (*SubscribeEngine) Start ¶
func (se *SubscribeEngine) Start()
func (*SubscribeEngine) Subscriber ¶
func (se *SubscribeEngine) Subscriber(options ...SubscribeOption) error
func (*SubscribeEngine) Use ¶
func (se *SubscribeEngine) Use(middleware ...HandlerFunc)
type SubscribeEngineOption ¶
type SubscribeEngineOption func(*SubscribeEngine)
func WithSubscribeEngineConf ¶
func WithSubscribeEngineConf(conf config.Config) SubscribeEngineOption
func WithSubscribeEngineLogger ¶
func WithSubscribeEngineLogger(logger log.Logger) SubscribeEngineOption
type SubscribeOption ¶
type SubscribeOption func(*Subscriber)
func WithSubscribeConcurrency ¶
func WithSubscribeConcurrency(curr int) SubscribeOption
func WithSubscribeGroupID ¶
func WithSubscribeGroupID(groupID string) SubscribeOption
func WithSubscribeHandlersChain ¶
func WithSubscribeHandlersChain(handlers ...HandlerFunc) SubscribeOption
func WithSubscribeMaxWait ¶
func WithSubscribeMaxWait(maxWait int) SubscribeOption
func WithSubscribeMessageNum ¶
func WithSubscribeMessageNum(messageNum int) SubscribeOption
func WithSubscribeMessageTag ¶
func WithSubscribeMessageTag(messageTag string) SubscribeOption
func WithSubscribeTopicName ¶
func WithSubscribeTopicName(topicName string) SubscribeOption
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
type TracePublisher ¶
type TracePublisher struct { *Publisher // contains filtered or unexported fields }
Publisher
type TraceSubscriber ¶
type TraceSubscriber struct { *SubscribeEngine // contains filtered or unexported fields }
Subscriber