home-services/gen/ha/v1/light_grpc.pb.go
Nik Afiq abb6774b77 feat: implement SwitchService with ListSwitches method
- Added ListSwitches method to SwitchService in switch_grpc.pb.go.
- Implemented SwitchGRPC adapter for ListSwitches in switch.go.
- Created SwitchApp for managing switch states and added ListSwitches logic.
- Updated core domain with Switch struct and associated methods.
- Enhanced LightApp to include ListLights functionality.
- Updated protobuf definitions for Switch and Light services to include new request and response messages.
- Introduced error handling for unimplemented methods in the gRPC server.
2026-04-06 19:25:06 +09:00

236 lines
8.8 KiB
Go

// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.6.1
// - protoc (unknown)
// source: ha/v1/light.proto
package hav1
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
LightService_TurnOn_FullMethodName = "/ha.v1.LightService/TurnOn"
LightService_TurnOff_FullMethodName = "/ha.v1.LightService/TurnOff"
LightService_Toggle_FullMethodName = "/ha.v1.LightService/Toggle"
LightService_ListLights_FullMethodName = "/ha.v1.LightService/ListLights"
)
// LightServiceClient is the client API for LightService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type LightServiceClient interface {
TurnOn(ctx context.Context, in *TurnOnRequest, opts ...grpc.CallOption) (*LightResponse, error)
TurnOff(ctx context.Context, in *TurnOffRequest, opts ...grpc.CallOption) (*LightResponse, error)
Toggle(ctx context.Context, in *ToggleRequest, opts ...grpc.CallOption) (*LightResponse, error)
ListLights(ctx context.Context, in *ListLightsRequest, opts ...grpc.CallOption) (*ListLightsResponse, error)
}
type lightServiceClient struct {
cc grpc.ClientConnInterface
}
func NewLightServiceClient(cc grpc.ClientConnInterface) LightServiceClient {
return &lightServiceClient{cc}
}
func (c *lightServiceClient) TurnOn(ctx context.Context, in *TurnOnRequest, opts ...grpc.CallOption) (*LightResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(LightResponse)
err := c.cc.Invoke(ctx, LightService_TurnOn_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *lightServiceClient) TurnOff(ctx context.Context, in *TurnOffRequest, opts ...grpc.CallOption) (*LightResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(LightResponse)
err := c.cc.Invoke(ctx, LightService_TurnOff_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *lightServiceClient) Toggle(ctx context.Context, in *ToggleRequest, opts ...grpc.CallOption) (*LightResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(LightResponse)
err := c.cc.Invoke(ctx, LightService_Toggle_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *lightServiceClient) ListLights(ctx context.Context, in *ListLightsRequest, opts ...grpc.CallOption) (*ListLightsResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListLightsResponse)
err := c.cc.Invoke(ctx, LightService_ListLights_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// LightServiceServer is the server API for LightService service.
// All implementations must embed UnimplementedLightServiceServer
// for forward compatibility.
type LightServiceServer interface {
TurnOn(context.Context, *TurnOnRequest) (*LightResponse, error)
TurnOff(context.Context, *TurnOffRequest) (*LightResponse, error)
Toggle(context.Context, *ToggleRequest) (*LightResponse, error)
ListLights(context.Context, *ListLightsRequest) (*ListLightsResponse, error)
mustEmbedUnimplementedLightServiceServer()
}
// UnimplementedLightServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedLightServiceServer struct{}
func (UnimplementedLightServiceServer) TurnOn(context.Context, *TurnOnRequest) (*LightResponse, error) {
return nil, status.Error(codes.Unimplemented, "method TurnOn not implemented")
}
func (UnimplementedLightServiceServer) TurnOff(context.Context, *TurnOffRequest) (*LightResponse, error) {
return nil, status.Error(codes.Unimplemented, "method TurnOff not implemented")
}
func (UnimplementedLightServiceServer) Toggle(context.Context, *ToggleRequest) (*LightResponse, error) {
return nil, status.Error(codes.Unimplemented, "method Toggle not implemented")
}
func (UnimplementedLightServiceServer) ListLights(context.Context, *ListLightsRequest) (*ListLightsResponse, error) {
return nil, status.Error(codes.Unimplemented, "method ListLights not implemented")
}
func (UnimplementedLightServiceServer) mustEmbedUnimplementedLightServiceServer() {}
func (UnimplementedLightServiceServer) testEmbeddedByValue() {}
// UnsafeLightServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to LightServiceServer will
// result in compilation errors.
type UnsafeLightServiceServer interface {
mustEmbedUnimplementedLightServiceServer()
}
func RegisterLightServiceServer(s grpc.ServiceRegistrar, srv LightServiceServer) {
// If the following call panics, it indicates UnimplementedLightServiceServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&LightService_ServiceDesc, srv)
}
func _LightService_TurnOn_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(TurnOnRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LightServiceServer).TurnOn(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: LightService_TurnOn_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LightServiceServer).TurnOn(ctx, req.(*TurnOnRequest))
}
return interceptor(ctx, in, info, handler)
}
func _LightService_TurnOff_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(TurnOffRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LightServiceServer).TurnOff(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: LightService_TurnOff_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LightServiceServer).TurnOff(ctx, req.(*TurnOffRequest))
}
return interceptor(ctx, in, info, handler)
}
func _LightService_Toggle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ToggleRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LightServiceServer).Toggle(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: LightService_Toggle_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LightServiceServer).Toggle(ctx, req.(*ToggleRequest))
}
return interceptor(ctx, in, info, handler)
}
func _LightService_ListLights_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListLightsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LightServiceServer).ListLights(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: LightService_ListLights_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LightServiceServer).ListLights(ctx, req.(*ListLightsRequest))
}
return interceptor(ctx, in, info, handler)
}
// LightService_ServiceDesc is the grpc.ServiceDesc for LightService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var LightService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "ha.v1.LightService",
HandlerType: (*LightServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "TurnOn",
Handler: _LightService_TurnOn_Handler,
},
{
MethodName: "TurnOff",
Handler: _LightService_TurnOff_Handler,
},
{
MethodName: "Toggle",
Handler: _LightService_Toggle_Handler,
},
{
MethodName: "ListLights",
Handler: _LightService_ListLights_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "ha/v1/light.proto",
}