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

package promo_campaign

import (
	"context"

	"github.com/golang/protobuf/proto"

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

const (
	UpdateEventType = "PromoCampaignUpdate"
)

type Update = PromoCampaignUpdate

type PromoCampaignUpdateHandler func(context.Context, *eventbus.Header, *PromoCampaignUpdate) error

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

func RegisterPromoCampaignUpdateHandler(mux *eventbus.Mux, f PromoCampaignUpdateHandler) {
	mux.RegisterHandler(UpdateEventType, f.Handler())
}

func RegisterUpdateHandler(mux *eventbus.Mux, f PromoCampaignUpdateHandler) {
	RegisterPromoCampaignUpdateHandler(mux, f)
}

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