// NOTE this is a generated file! do not edit!

package entitlement_subscription

import (
	"context"

	"github.com/golang/protobuf/proto"

	eventbus "code.justin.tv/eventbus/client"
)

const (
	UpdateEventType = "EntitlementSubscriptionUpdate"
)

type Update = EntitlementSubscriptionUpdate

type EntitlementSubscriptionUpdateHandler func(context.Context, *eventbus.Header, *EntitlementSubscriptionUpdate) error

func (h EntitlementSubscriptionUpdateHandler) Handler() eventbus.Handler {
	return func(ctx context.Context, message eventbus.RawMessage) error {
		dst := &EntitlementSubscriptionUpdate{}
		err := proto.Unmarshal(message.Payload, dst)
		if err != nil {
			return err
		}
		return h(ctx, message.Header, dst)
	}
}

func RegisterEntitlementSubscriptionUpdateHandler(mux *eventbus.Mux, f EntitlementSubscriptionUpdateHandler) {
	mux.RegisterHandler(UpdateEventType, f.Handler())
}

func RegisterUpdateHandler(mux *eventbus.Mux, f EntitlementSubscriptionUpdateHandler) {
	RegisterEntitlementSubscriptionUpdateHandler(mux, f)
}

func (*EntitlementSubscriptionUpdate) EventBusName() string {
	return UpdateEventType
}
