[FEATURE] micro v4 prepare changes #194

Open
opened 2023-03-18 00:27:18 +03:00 by vtolstov · 0 comments
Owner

change all build contains for interface to

_ connector.CallbackConnector = (*giteaConnector)(nil)
  • add to all packages option WithMiddlewares(...Middleware) Option for each stuff
  • type Middleware any in micro/v3
  • create Middleware interface for each method for each stuff

broker:

type MiddlewarePublisher interface {
	Publish(ctx context.Context, topic string, msg *Message, opts ...PublishOption) error
}

type MiddlewareSubscriber interface {
	Subscribe(ctx context.Context, topic string, h Handler, opts ...SubscribeOption) (Subscriber, error)
}

type MiddlewareBatchPublisher interface {
	BatchPublish(ctx context.Context, msgs []*Message, opts ...PublishOption) error
}

type MiddlewareBatchSubscriber interface {
	BatchSubscribe(ctx context.Context, topic string, h BatchHandler, opts ...SubscribeOption) (Subscriber, error)

client:

type MiddlewareCaller interface {
	Call(ctx context.Context, req Request, rsp interface{}, opts ...CallOption) error
}

type MiddlewareStreamer interface {
    Stream(ctx context.Context, req Request, opts ...CallOption) (Stream, error)
}

type MiddlewarePublisher interface {
	Publish(ctx context.Context, msg Message, opts ...PublishOption) error
}

type MiddlewareBatchPublisher interface {
	BatchPublish(ctx context.Context, msg []Message, opts ...PublishOption) error
}

server:

type MiddlewareHandler interface {
	Handler(ctx context.Context, req Request, rsp interface{}) error
}

type middlewareSubscriber interface {
	Subscriber(ctx context.Context, msg Message) error
}
  • add to all packages option WithHooks(...Hook) Option for each stuff
  • create Hook interface for each method for each stuff
type Hook interface{}

type Hooks []Hook

func (hs *hooks) Each(fn func(Hook)) {
  for _, h := range *hs {
    fn(h)
  }
}

func (hs *hooks) Append(h ...Hook) {
  *hs = append(*hs, h...)
}

func (hs *hooks) Replace(h ...Hook) {
  *hs = h
}

  • type Hooks []Hook
  • func (s Hooks) Each

store:

type HookInit interface {
	Init(...Option) error
}

change all build contains for interface to ``` _ connector.CallbackConnector = (*giteaConnector)(nil) ``` * add to all packages option WithMiddlewares(...Middleware) Option for each stuff * type Middleware any in micro/v3 * create Middleware interface for each method for each stuff broker: ``` type MiddlewarePublisher interface { Publish(ctx context.Context, topic string, msg *Message, opts ...PublishOption) error } type MiddlewareSubscriber interface { Subscribe(ctx context.Context, topic string, h Handler, opts ...SubscribeOption) (Subscriber, error) } type MiddlewareBatchPublisher interface { BatchPublish(ctx context.Context, msgs []*Message, opts ...PublishOption) error } type MiddlewareBatchSubscriber interface { BatchSubscribe(ctx context.Context, topic string, h BatchHandler, opts ...SubscribeOption) (Subscriber, error) ``` client: ``` type MiddlewareCaller interface { Call(ctx context.Context, req Request, rsp interface{}, opts ...CallOption) error } type MiddlewareStreamer interface { Stream(ctx context.Context, req Request, opts ...CallOption) (Stream, error) } type MiddlewarePublisher interface { Publish(ctx context.Context, msg Message, opts ...PublishOption) error } type MiddlewareBatchPublisher interface { BatchPublish(ctx context.Context, msg []Message, opts ...PublishOption) error } ``` server: ``` type MiddlewareHandler interface { Handler(ctx context.Context, req Request, rsp interface{}) error } type middlewareSubscriber interface { Subscriber(ctx context.Context, msg Message) error } ``` * add to all packages option WithHooks(...Hook) Option for each stuff * create Hook interface for each method for each stuff ``` type Hook interface{} type Hooks []Hook func (hs *hooks) Each(fn func(Hook)) { for _, h := range *hs { fn(h) } } func (hs *hooks) Append(h ...Hook) { *hs = append(*hs, h...) } func (hs *hooks) Replace(h ...Hook) { *hs = h } ``` * type Hooks []Hook * func (s Hooks) Each store: ``` type HookInit interface { Init(...Option) error } ```
vtolstov changed title from [FEATURE] replace wrappers with Hooks to [FEATURE] micro v4 prepare changes 2023-03-18 11:20:05 +03:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: unistack-org/micro#194
No description provided.