//go:build !ignore_autogenerated
// +build !ignore_autogenerated

// Code generated by iocli, run 'iocli gen' to re-generate

package rocketmq

import (
	contextx "context"

	"github.com/apache/rocketmq-client-go/v2/admin"
	"github.com/apache/rocketmq-client-go/v2/consumer"
	"github.com/apache/rocketmq-client-go/v2/primitive"

	autowire "github.com/alibaba/ioc-golang/autowire"
	normal "github.com/alibaba/ioc-golang/autowire/normal"
	singleton "github.com/alibaba/ioc-golang/autowire/singleton"
	util "github.com/alibaba/ioc-golang/autowire/util"
)

func init() {
	normal.RegisterStructDescriptor(&autowire.StructDescriptor{
		Factory: func() interface{} {
			return &pushConsumer_{}
		},
	})
	pushConsumerStructDescriptor := &autowire.StructDescriptor{
		Factory: func() interface{} {
			return &PushConsumer{}
		},
		ParamFactory: func() interface{} {
			var _ pushConsumerParamInterface = &PushConsumerParam{}
			return &PushConsumerParam{}
		},
		ConstructFunc: func(i interface{}, p interface{}) (interface{}, error) {
			param := p.(pushConsumerParamInterface)
			impl := i.(*PushConsumer)
			return param.New(impl)
		},
		Metadata: map[string]interface{}{
			"aop":      map[string]interface{}{},
			"autowire": map[string]interface{}{},
		},
	}
	normal.RegisterStructDescriptor(pushConsumerStructDescriptor)
	singleton.RegisterStructDescriptor(pushConsumerStructDescriptor)
	normal.RegisterStructDescriptor(&autowire.StructDescriptor{
		Factory: func() interface{} {
			return &producer_{}
		},
	})
	producerStructDescriptor := &autowire.StructDescriptor{
		Factory: func() interface{} {
			return &Producer{}
		},
		ParamFactory: func() interface{} {
			var _ producerParamInterface = &ProducerParam{}
			return &ProducerParam{}
		},
		ConstructFunc: func(i interface{}, p interface{}) (interface{}, error) {
			param := p.(producerParamInterface)
			impl := i.(*Producer)
			return param.New(impl)
		},
		Metadata: map[string]interface{}{
			"aop":      map[string]interface{}{},
			"autowire": map[string]interface{}{},
		},
	}
	normal.RegisterStructDescriptor(producerStructDescriptor)
	singleton.RegisterStructDescriptor(producerStructDescriptor)
	normal.RegisterStructDescriptor(&autowire.StructDescriptor{
		Factory: func() interface{} {
			return &admin_{}
		},
	})
	adminStructDescriptor := &autowire.StructDescriptor{
		Factory: func() interface{} {
			return &Admin{}
		},
		ParamFactory: func() interface{} {
			var _ adminParamInterface = &AdminParam{}
			return &AdminParam{}
		},
		ConstructFunc: func(i interface{}, p interface{}) (interface{}, error) {
			param := p.(adminParamInterface)
			impl := i.(*Admin)
			return param.New(impl)
		},
		Metadata: map[string]interface{}{
			"aop":      map[string]interface{}{},
			"autowire": map[string]interface{}{},
		},
	}
	normal.RegisterStructDescriptor(adminStructDescriptor)
	singleton.RegisterStructDescriptor(adminStructDescriptor)
}

type pushConsumerParamInterface interface {
	New(impl *PushConsumer) (*PushConsumer, error)
}
type producerParamInterface interface {
	New(impl *Producer) (*Producer, error)
}
type adminParamInterface interface {
	New(impl *Admin) (*Admin, error)
}
type pushConsumer_ struct {
	Start_       func() error
	Shutdown_    func() error
	Subscribe_   func(topic string, selector consumer.MessageSelector, f func(contextx.Context, ...*primitive.MessageExt) (consumer.ConsumeResult, error)) error
	Unsubscribe_ func(topic string) error
}

func (p *pushConsumer_) Start() error {
	return p.Start_()
}

func (p *pushConsumer_) Shutdown() error {
	return p.Shutdown_()
}

func (p *pushConsumer_) Subscribe(topic string, selector consumer.MessageSelector, f func(contextx.Context, ...*primitive.MessageExt) (consumer.ConsumeResult, error)) error {
	return p.Subscribe_(topic, selector, f)
}

func (p *pushConsumer_) Unsubscribe(topic string) error {
	return p.Unsubscribe_(topic)
}

type producer_ struct {
	Start_      func() error
	Shutdown_   func() error
	SendSync_   func(ctx contextx.Context, mq ...*primitive.Message) (*primitive.SendResult, error)
	SendAsync_  func(ctx contextx.Context, mq func(ctx contextx.Context, result *primitive.SendResult, err error), msg ...*primitive.Message) error
	SendOneWay_ func(ctx contextx.Context, mq ...*primitive.Message) error
}

func (p *producer_) Start() error {
	return p.Start_()
}

func (p *producer_) Shutdown() error {
	return p.Shutdown_()
}

func (p *producer_) SendSync(ctx contextx.Context, mq ...*primitive.Message) (*primitive.SendResult, error) {
	return p.SendSync_(ctx, mq...)
}

func (p *producer_) SendAsync(ctx contextx.Context, mq func(ctx contextx.Context, result *primitive.SendResult, err error), msg ...*primitive.Message) error {
	return p.SendAsync_(ctx, mq, msg...)
}

func (p *producer_) SendOneWay(ctx contextx.Context, mq ...*primitive.Message) error {
	return p.SendOneWay_(ctx, mq...)
}

type admin_ struct {
	CreateTopic_ func(ctx contextx.Context, opts ...admin.OptionCreate) error
	DeleteTopic_ func(ctx contextx.Context, opts ...admin.OptionDelete) error
	Close_       func() error
}

func (a *admin_) CreateTopic(ctx contextx.Context, opts ...admin.OptionCreate) error {
	return a.CreateTopic_(ctx, opts...)
}

func (a *admin_) DeleteTopic(ctx contextx.Context, opts ...admin.OptionDelete) error {
	return a.DeleteTopic_(ctx, opts...)
}

func (a *admin_) Close() error {
	return a.Close_()
}

type PushConsumerIOCInterface interface {
	Start() error
	Shutdown() error
	Subscribe(topic string, selector consumer.MessageSelector, f func(contextx.Context, ...*primitive.MessageExt) (consumer.ConsumeResult, error)) error
	Unsubscribe(topic string) error
}

type ProducerIOCInterface interface {
	Start() error
	Shutdown() error
	SendSync(ctx contextx.Context, mq ...*primitive.Message) (*primitive.SendResult, error)
	SendAsync(ctx contextx.Context, mq func(ctx contextx.Context, result *primitive.SendResult, err error), msg ...*primitive.Message) error
	SendOneWay(ctx contextx.Context, mq ...*primitive.Message) error
}

type AdminIOCInterface interface {
	CreateTopic(ctx contextx.Context, opts ...admin.OptionCreate) error
	DeleteTopic(ctx contextx.Context, opts ...admin.OptionDelete) error
	Close() error
}

var _pushConsumerSDID string

func GetPushConsumer(p *PushConsumerParam) (*PushConsumer, error) {
	if _pushConsumerSDID == "" {
		_pushConsumerSDID = util.GetSDIDByStructPtr(new(PushConsumer))
	}
	i, err := normal.GetImpl(_pushConsumerSDID, p)
	if err != nil {
		return nil, err
	}
	impl := i.(*PushConsumer)
	return impl, nil
}

func GetPushConsumerIOCInterface(p *PushConsumerParam) (PushConsumerIOCInterface, error) {
	if _pushConsumerSDID == "" {
		_pushConsumerSDID = util.GetSDIDByStructPtr(new(PushConsumer))
	}
	i, err := normal.GetImplWithProxy(_pushConsumerSDID, p)
	if err != nil {
		return nil, err
	}
	impl := i.(PushConsumerIOCInterface)
	return impl, nil
}

func GetPushConsumerSingleton(p *PushConsumerParam) (*PushConsumer, error) {
	if _pushConsumerSDID == "" {
		_pushConsumerSDID = util.GetSDIDByStructPtr(new(PushConsumer))
	}
	i, err := singleton.GetImpl(_pushConsumerSDID, p)
	if err != nil {
		return nil, err
	}
	impl := i.(*PushConsumer)
	return impl, nil
}

func GetPushConsumerIOCInterfaceSingleton(p *PushConsumerParam) (PushConsumerIOCInterface, error) {
	if _pushConsumerSDID == "" {
		_pushConsumerSDID = util.GetSDIDByStructPtr(new(PushConsumer))
	}
	i, err := singleton.GetImplWithProxy(_pushConsumerSDID, p)
	if err != nil {
		return nil, err
	}
	impl := i.(PushConsumerIOCInterface)
	return impl, nil
}

type ThisPushConsumer struct {
}

func (t *ThisPushConsumer) This() PushConsumerIOCInterface {
	thisPtr, _ := GetPushConsumerIOCInterfaceSingleton(nil)
	return thisPtr
}

var _producerSDID string

func GetProducer(p *ProducerParam) (*Producer, error) {
	if _producerSDID == "" {
		_producerSDID = util.GetSDIDByStructPtr(new(Producer))
	}
	i, err := normal.GetImpl(_producerSDID, p)
	if err != nil {
		return nil, err
	}
	impl := i.(*Producer)
	return impl, nil
}

func GetProducerIOCInterface(p *ProducerParam) (ProducerIOCInterface, error) {
	if _producerSDID == "" {
		_producerSDID = util.GetSDIDByStructPtr(new(Producer))
	}
	i, err := normal.GetImplWithProxy(_producerSDID, p)
	if err != nil {
		return nil, err
	}
	impl := i.(ProducerIOCInterface)
	return impl, nil
}

func GetProducerSingleton(p *ProducerParam) (*Producer, error) {
	if _producerSDID == "" {
		_producerSDID = util.GetSDIDByStructPtr(new(Producer))
	}
	i, err := singleton.GetImpl(_producerSDID, p)
	if err != nil {
		return nil, err
	}
	impl := i.(*Producer)
	return impl, nil
}

func GetProducerIOCInterfaceSingleton(p *ProducerParam) (ProducerIOCInterface, error) {
	if _producerSDID == "" {
		_producerSDID = util.GetSDIDByStructPtr(new(Producer))
	}
	i, err := singleton.GetImplWithProxy(_producerSDID, p)
	if err != nil {
		return nil, err
	}
	impl := i.(ProducerIOCInterface)
	return impl, nil
}

type ThisProducer struct {
}

func (t *ThisProducer) This() ProducerIOCInterface {
	thisPtr, _ := GetProducerIOCInterfaceSingleton(nil)
	return thisPtr
}

var _adminSDID string

func GetAdmin(p *AdminParam) (*Admin, error) {
	if _adminSDID == "" {
		_adminSDID = util.GetSDIDByStructPtr(new(Admin))
	}
	i, err := normal.GetImpl(_adminSDID, p)
	if err != nil {
		return nil, err
	}
	impl := i.(*Admin)
	return impl, nil
}

func GetAdminIOCInterface(p *AdminParam) (AdminIOCInterface, error) {
	if _adminSDID == "" {
		_adminSDID = util.GetSDIDByStructPtr(new(Admin))
	}
	i, err := normal.GetImplWithProxy(_adminSDID, p)
	if err != nil {
		return nil, err
	}
	impl := i.(AdminIOCInterface)
	return impl, nil
}

func GetAdminSingleton(p *AdminParam) (*Admin, error) {
	if _adminSDID == "" {
		_adminSDID = util.GetSDIDByStructPtr(new(Admin))
	}
	i, err := singleton.GetImpl(_adminSDID, p)
	if err != nil {
		return nil, err
	}
	impl := i.(*Admin)
	return impl, nil
}

func GetAdminIOCInterfaceSingleton(p *AdminParam) (AdminIOCInterface, error) {
	if _adminSDID == "" {
		_adminSDID = util.GetSDIDByStructPtr(new(Admin))
	}
	i, err := singleton.GetImplWithProxy(_adminSDID, p)
	if err != nil {
		return nil, err
	}
	impl := i.(AdminIOCInterface)
	return impl, nil
}

type ThisAdmin struct {
}

func (t *ThisAdmin) This() AdminIOCInterface {
	thisPtr, _ := GetAdminIOCInterfaceSingleton(nil)
	return thisPtr
}
