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

package poll_synchronization

import (
	"context"

	"github.com/golang/protobuf/proto"

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

const (
	UpdateEventType = "PollSynchronizationUpdate"
)

type Update = PollSynchronizationUpdate

type PollSynchronizationUpdateHandler func(context.Context, *eventbus.Header, *PollSynchronizationUpdate) error

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

func RegisterPollSynchronizationUpdateHandler(mux *eventbus.Mux, f PollSynchronizationUpdateHandler) {
	mux.RegisterHandler(UpdateEventType, f.Handler())
}

func RegisterUpdateHandler(mux *eventbus.Mux, f PollSynchronizationUpdateHandler) {
	RegisterPollSynchronizationUpdateHandler(mux, f)
}

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