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

package commercial

import (
	"context"

	"github.com/golang/protobuf/proto"

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

const (
	UpdateEventType = "CommercialUpdate"
)

type Update = CommercialUpdate

type CommercialUpdateHandler func(context.Context, *eventbus.Header, *CommercialUpdate) error

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

func RegisterCommercialUpdateHandler(mux *eventbus.Mux, f CommercialUpdateHandler) {
	mux.RegisterHandler(UpdateEventType, f.Handler())
}

func RegisterUpdateHandler(mux *eventbus.Mux, f CommercialUpdateHandler) {
	RegisterCommercialUpdateHandler(mux, f)
}

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