Documentation
¶
Index ¶
- Constants
- func ForceRetry(errs ...error) error
- func Publish(jobCli *Client, ctx context.Context, topic string, args proto.Message, ...) result.Result[*PubAckInfo]
- func Redelivery(delay time.Duration, errs ...error) error
- func RegisterJobHandler[T proto.Message](jobCli *Client, jobName, topic string, handler Handler[T], opts ...RegisterOpt)
- func Reject(errs ...error) error
- func WithPushOpt(opts ...func(opt *cloudeventpb.PushEventOptions)) *cloudeventpb.PushEventOptions
- func WrapHandler[Req, Rsp proto.Message](handler func(ctx context.Context, req Req) (Rsp, error)) func(ctx context.Context, req Req) error
- type Client
- type Config
- type Consumer
- type ConsumerConfig
- type Context
- type Handler
- type JobEventConfig
- type Params
- type PubAckInfo
- type PubInterceptFunc
- type PubInterceptor
- type PubOpt
- type PubOptions
- type Register
- type RegisterJobOptions
- type RegisterOpt
- type RpcHandler
- type StreamConfig
- type SubInterceptFunc
- type SubInterceptor
Examples ¶
Constants ¶
View Source
const ( DefaultPrefix = "acj" DefaultTimeout = 15 * time.Second DefaultMaxRetry = 3 DefaultRetryBackoff = time.Second SenderHeaderKey = "__cloudevent_sender" DelayHeaderKey = "__cloudevent_delay_run_at" DefaultJobName = "default" DefaultConcurrent = 100 DefaultMaxConcurrent = 1000 DefaultMinConcurrent = 1 )
Variables ¶
This section is empty.
Functions ¶
func ForceRetry ¶ added in v2.0.4
func RegisterJobHandler ¶
func WithPushOpt ¶
func WithPushOpt(opts ...func(opt *cloudeventpb.PushEventOptions)) *cloudeventpb.PushEventOptions
Example ¶
package main
import (
"fmt"
"github.com/samber/lo"
"github.com/pubgo/funk/v2/component/cloudevent"
cloudeventpb "github.com/pubgo/funk/v2/proto/cloudevent"
)
func main() {
opt := cloudevent.WithPushOpt(func(o *cloudeventpb.PushEventOptions) {
o.ContentType = lo.ToPtr("application/protobuf")
})
fmt.Println(opt.GetContentType())
}
Output: application/protobuf
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) GetSubject ¶
func (c *Client) GetSubject(name string) *cloudeventpb.CloudEventMethodOptions
type Config ¶
type Config struct {
Streams map[string]*StreamConfig `yaml:"streams"`
Consumers map[string]typex.YamlListType[*ConsumerConfig] `yaml:"consumers"`
}
type Consumer ¶
type Consumer struct {
jetstream.Consumer
Config *ConsumerConfig
}
type ConsumerConfig ¶
type ConsumerConfig struct {
Consumer *string `yaml:"consumer"`
Concurrent *int `yaml:"concurrent"`
Stream string `yaml:"stream"`
Subjects typex.YamlListType[*strOrJobConfig] `yaml:"subjects"`
Job *JobEventConfig `yaml:"job"`
}
type Context ¶
type Context struct {
Header http.Header
NumDelivered uint64
NumPending uint64
Timestamp time.Time
Stream string
Consumer string
Subject string
Config *JobEventConfig
}
func GetContext ¶ added in v2.0.4
type JobEventConfig ¶
type PubAckInfo ¶
type PubInterceptFunc ¶ added in v2.0.4
type PubInterceptFunc func(ctx context.Context, topic string, args proto.Message, opts *PubOptions, handler func(ctx context.Context, topic string, args proto.Message, opts *PubOptions) result.Result[*PubAckInfo]) result.Result[*PubAckInfo]
type PubInterceptor ¶ added in v2.0.4
type PubInterceptor func(next PubInterceptFunc) PubInterceptFunc
type PubOpt ¶ added in v2.0.4
type PubOpt func(opts *PubOptions)
func ProtoPubOpts ¶ added in v2.0.4
func ProtoPubOpts(opts ...*cloudeventpb.PushEventOptions) []PubOpt
type PubOptions ¶ added in v2.0.4
type PubOptions = cloudeventpb.PushEventOptions
type RegisterJobOptions ¶ added in v2.0.4
type RegisterJobOptions struct {
Opts *cloudeventpb.RegisterJobOptions
Interceptors []SubInterceptor
}
type RegisterOpt ¶ added in v2.0.4
type RegisterOpt func(opts *RegisterJobOptions)
func ProtoRegisterOpts ¶ added in v2.0.4
func ProtoRegisterOpts(opts ...*cloudeventpb.RegisterJobOptions) RegisterOpt
Example ¶
package main
import (
"fmt"
"github.com/samber/lo"
"github.com/pubgo/funk/v2/component/cloudevent"
cloudeventpb "github.com/pubgo/funk/v2/proto/cloudevent"
)
func main() {
opt := cloudevent.ProtoRegisterOpts(&cloudeventpb.RegisterJobOptions{
JobName: lo.ToPtr("demo"),
})
ro := &cloudevent.RegisterJobOptions{Opts: new(cloudeventpb.RegisterJobOptions)}
opt(ro)
fmt.Println(lo.FromPtr(ro.Opts.JobName))
}
Output: demo
func WithSubInterceptors ¶ added in v2.0.4
func WithSubInterceptors(interceptors ...SubInterceptor) RegisterOpt
type RpcHandler ¶ added in v2.0.4
type StreamConfig ¶
type StreamConfig struct {
Storage string `yaml:"storage"`
Subjects typex.YamlListType[string] `yaml:"subjects"`
}
type SubInterceptFunc ¶ added in v2.0.4
type SubInterceptor ¶ added in v2.0.4
type SubInterceptor func(next SubInterceptFunc) SubInterceptFunc
Source Files
¶
Click to show internal directories.
Click to hide internal directories.