rocketmq

package
v0.0.0-...-6d34543 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

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

func (c *Context) AbortWithError(err error) *Error

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) Ack

func (c *Context) Ack()

func (*Context) BindJSON

func (c *Context) BindJSON(obj interface{}) error

BindJSON is a shortcut for c.MustBindWith(obj, binding.JSON).

func (*Context) BindProtoBuf

func (c *Context) BindProtoBuf(obj interface{}) error

BindQuery is a shortcut for c.MustBindWith(obj, binding.Query).

func (*Context) BindXML

func (c *Context) BindXML(obj interface{}) error

BindXML is a shortcut for c.MustBindWith(obj, binding.BindXML).

func (*Context) BindYAML

func (c *Context) BindYAML(obj interface{}) error

BindYAML is a shortcut for c.MustBindWith(obj, binding.YAML).

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) Context

func (c *Context) Context() context.Context

func (*Context) Copy

func (c *Context) Copy() *Context

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

func (c *Context) Error(err error) *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

func (c *Context) Get(key string) (value interface{}, exists bool)

Get returns the value for the given key, ie: (value, true). If the value does not exists it returns (nil, false)

func (*Context) GetBool

func (c *Context) GetBool(key string) (b bool)

GetBool returns the value associated with the key as a boolean.

func (*Context) GetDuration

func (c *Context) GetDuration(key string) (d time.Duration)

GetDuration returns the value associated with the key as a duration.

func (*Context) GetFloat64

func (c *Context) GetFloat64(key string) (f64 float64)

GetFloat64 returns the value associated with the key as a float64.

func (*Context) GetInt

func (c *Context) GetInt(key string) (i int)

GetInt returns the value associated with the key as an integer.

func (*Context) GetInt64

func (c *Context) GetInt64(key string) (i64 int64)

GetInt64 returns the value associated with the key as an integer.

func (*Context) GetString

func (c *Context) GetString(key string) (s string)

GetString returns the value associated with the key as a string.

func (*Context) GetStringMap

func (c *Context) GetStringMap(key string) (sm map[string]interface{})

GetStringMap returns the value associated with the key as a map of interfaces.

func (*Context) GetStringMapString

func (c *Context) GetStringMapString(key string) (sms map[string]string)

GetStringMapString returns the value associated with the key as a map of strings.

func (*Context) GetStringMapStringSlice

func (c *Context) GetStringMapStringSlice(key string) (smss map[string][]string)

GetStringMapStringSlice returns the value associated with the key as a map to a slice of strings.

func (*Context) GetStringSlice

func (c *Context) GetStringSlice(key string) (ss []string)

GetStringSlice returns the value associated with the key as a slice of strings.

func (*Context) GetTime

func (c *Context) GetTime(key string) (t time.Time)

GetTime returns the value associated with the key as time.

func (*Context) Handler

func (c *Context) Handler() HandlerFunc

Handler returns the main handler.

func (*Context) HandlerName

func (c *Context) HandlerName() string

HandlerName returns the main handler's name. For example if the handler is "handleGetUsers()", this function will return "main.handleGetUsers".

func (*Context) HandlerNames

func (c *Context) HandlerNames() []string

HandlerNames returns a list of all registered handlers for this context in descending order, following the semantics of HandlerName()

func (*Context) IsAborted

func (c *Context) IsAborted() bool

IsAborted returns true if the current context was aborted.

func (*Context) IsAck

func (c *Context) IsAck() bool

func (*Context) MustBindWith

func (c *Context) MustBindWith(obj interface{}, b binding.Binding) error

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

func (c *Context) MustGet(key string) interface{}

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

func (c *Context) Set(key string, value interface{})

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

func (c *Context) ShouldBindJSON(obj interface{}) error

ShouldBindJSON is a shortcut for c.ShouldBindWith(obj, binding.JSON).

func (*Context) ShouldBindWith

func (c *Context) ShouldBindWith(obj interface{}, b binding.Binding) error

ShouldBindWith binds the passed struct pointer using the specified binding engine. See the binding package.

func (*Context) ShouldBindXML

func (c *Context) ShouldBindXML(obj interface{}) error

ShouldBindXML is a shortcut for c.ShouldBindWith(obj, binding.XML).

func (*Context) ShouldBindYAML

func (c *Context) ShouldBindYAML(obj interface{}) error

ShouldBindYAML is a shortcut for c.ShouldBindWith(obj, binding.YAML).

func (*Context) Topic

func (c *Context) Topic() string

type Error

type Error struct {
	Err  error
	Type ErrorType
	Meta interface{}
}

Error represents a error's specification.

func (Error) Error

func (msg Error) Error() string

Error implements the error interface.

func (*Error) IsType

func (msg *Error) IsType(flags ErrorType) bool

IsType judges one error.

func (*Error) JSON

func (msg *Error) JSON() interface{}

JSON creates a properly formatted JSON

func (*Error) MarshalJSON

func (msg *Error) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface.

func (*Error) SetMeta

func (msg *Error) SetMeta(data interface{}) *Error

SetMeta sets the error's meta data.

func (*Error) SetType

func (msg *Error) SetType(flags ErrorType) *Error

SetType sets the error's type.

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 H

type H map[string]interface{}

H is a shortcut for map[string]interface{}

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 NewMQClient(options ...Option) *MQClient

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) WithConf

func (MQClientOptions) WithConf(conf config.Config) Option

func (MQClientOptions) WithLogger

func (MQClientOptions) WithLogger(logger log.Logger) Option

type Option

type Option func(*MQClient)

type Publisher

type Publisher struct {
	// contains filtered or unexported fields
}

func NewPublisher

func NewPublisher(options ...PublisherOption) *Publisher

func (*Publisher) PublishDelayMessage

func (p *Publisher) PublishDelayMessage(ctx context.Context, topicName, messageBody string, delay time.Duration) error

func (*Publisher) PublishDelayMessageProt

func (p *Publisher) PublishDelayMessageProt(ctx context.Context, topicName, messageBody string, properties map[string]string, delay time.Duration) error

func (*Publisher) PublishDelayMsgWithKeyTag

func (p *Publisher) PublishDelayMsgWithKeyTag(ctx context.Context, topicName, messageBody, messageTag, messageKey string, delay time.Duration) error

func (*Publisher) PublishDelayMsgWithTag

func (p *Publisher) PublishDelayMsgWithTag(ctx context.Context, topicName, messageBody, messageTag string, delay time.Duration) error

func (*Publisher) PublishMessage

func (p *Publisher) PublishMessage(ctx context.Context, topicName, messageBody string) error

func (*Publisher) PublishMessageProp

func (p *Publisher) PublishMessageProp(ctx context.Context, topicName, messageTag, messageBody string, properties map[string]string) error

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL