//go:build stub
// +build stub

package website

import (
	"context"

	"google.golang.org/grpc"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
)

type Event struct {
	Type string `json:"type"`
	Msg  []byte `json:"msg"`
}

func (e *Event) GetType() string {
	return e.Type
}

func (e *Event) GetMsg() []byte {
	return e.Msg
}

type Response struct {
	Type string `json:"type"`
	Err  bool   `json:"err"`
	Msg  []byte `json:"msg"`
}

func (r *Response) GetType() string {
	return r.Type
}

func (r *Response) GetErr() bool {
	return r.Err
}

func (r *Response) GetMsg() []byte {
	return r.Msg
}

type Website_SubscribeServer interface {
	Send(*Event) error
	Recv() (*Response, error)
	grpc.ServerStream
}

type UnimplementedWebsiteServer struct{}

func (UnimplementedWebsiteServer) Subscribe(stream Website_SubscribeServer) error {
	return status.Errorf(codes.Unimplemented, "method Subscribe not implemented")
}

func RegisterWebsiteServer(s grpc.ServiceRegistrar, srv WebsiteServer) {
	s.RegisterService(&_Website_ServiceDesc, srv)
}

type WebsiteServer interface {
	Subscribe(Website_SubscribeServer) error
}

var _Website_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "website.Website",
	HandlerType: (*WebsiteServer)(nil),
	Methods:     []grpc.MethodDesc{},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "Subscribe",
			Handler:       nil,
			ServerStreams:  true,
			ClientStreams:  true,
		},
	},
	Metadata: "website.proto",
}

// Client-side types

type WebsiteClient interface {
	Subscribe(ctx context.Context, opts ...grpc.CallOption) (Website_SubscribeClient, error)
}

type Website_SubscribeClient interface {
	Send(*Response) error
	Recv() (*Event, error)
	grpc.ClientStream
}

type websiteClient struct {
	cc grpc.ClientConnInterface
}

func NewWebsiteClient(cc grpc.ClientConnInterface) WebsiteClient {
	return &websiteClient{cc}
}

func (c *websiteClient) Subscribe(ctx context.Context, opts ...grpc.CallOption) (Website_SubscribeClient, error) {
	stream, err := c.cc.NewStream(ctx, &_Website_ServiceDesc.Streams[0], "website.Website.Subscribe", opts...)
	if err != nil {
		return nil, err
	}
	return &websiteSubscribeClient{stream}, nil
}

type websiteSubscribeClient struct {
	grpc.ClientStream
}

func (x *websiteSubscribeClient) Send(m *Response) error {
	return x.ClientStream.SendMsg(m)
}

func (x *websiteSubscribeClient) Recv() (*Event, error) {
	m := new(Event)
	if err := x.ClientStream.RecvMsg(m); err != nil {
		return nil, err
	}
	return m, nil
}
