Documentation
¶
Overview ¶
Package simple demonstrates basic proto-cli usage with unary gRPC methods.
This example shows how to:
- Define gRPC services with CLI annotations
- Configure service and command names via (cli.service) and (cli.command)
- Customize flag names, usage text, and shorthand aliases
- Use nested configuration messages with factory functions
- Support both direct invocation and remote gRPC calls
- Handle custom deserializers for complex types (timestamps, nested messages)
- Load configuration from files and environment variables
- Use optional proto3 fields with explicit presence tracking
The example includes two services:
- UserService: Demonstrates CRUD operations with custom config loading
- AdminService: Shows service name overrides and simple operations
Command Structures:
- Nested (default): go run ./usercli user-service get --id 1
- Flat (single-service): go run ./usercli_flat get --id 1
To run the example:
go run ./usercli user-service get --id 1 go run ./usercli admin health-check go run ./usercli_flat get --id 1 # flat structure
Generated code in this package should not be edited manually. To regenerate after modifying example.proto, run: go generate
Index ¶
- Constants
- Variables
- func AdminServiceCommand(ctx context.Context, implOrFactory interface{}, opts ...protocli.ServiceOption) *protocli.ServiceCLI
- func AdminServiceCommandsFlat(ctx context.Context, implOrFactory interface{}, opts ...protocli.ServiceOption) []*v3.Command
- func RegisterAdminServiceServer(s grpc.ServiceRegistrar, srv AdminServiceServer)
- func RegisterUserServiceServer(s grpc.ServiceRegistrar, srv UserServiceServer)
- func UserServiceCommand(ctx context.Context, implOrFactory interface{}, opts ...protocli.ServiceOption) *protocli.ServiceCLI
- func UserServiceCommandsFlat(ctx context.Context, implOrFactory interface{}, opts ...protocli.ServiceOption) []*v3.Command
- type Address
- func (*Address) Descriptor() ([]byte, []int)deprecated
- func (x *Address) GetCity() string
- func (x *Address) GetCountry() string
- func (x *Address) GetState() string
- func (x *Address) GetStreet() string
- func (x *Address) GetZipCode() string
- func (*Address) ProtoMessage()
- func (x *Address) ProtoReflect() protoreflect.Message
- func (x *Address) Reset()
- func (x *Address) String() string
- type AdminRequest
- type AdminResponse
- func (*AdminResponse) Descriptor() ([]byte, []int)deprecated
- func (x *AdminResponse) GetMessage() string
- func (x *AdminResponse) GetSuccess() bool
- func (*AdminResponse) ProtoMessage()
- func (x *AdminResponse) ProtoReflect() protoreflect.Message
- func (x *AdminResponse) Reset()
- func (x *AdminResponse) String() string
- type AdminServiceClient
- type AdminServiceServer
- type CreateUserRequest
- func (*CreateUserRequest) Descriptor() ([]byte, []int)deprecated
- func (x *CreateUserRequest) GetAddress() *Address
- func (x *CreateUserRequest) GetAge() int32
- func (x *CreateUserRequest) GetEmail() string
- func (x *CreateUserRequest) GetLogLevel() LogLevel
- func (x *CreateUserRequest) GetName() string
- func (x *CreateUserRequest) GetNickname() string
- func (x *CreateUserRequest) GetPhoneNumber() string
- func (x *CreateUserRequest) GetRegistrationDate() *timestamppb.Timestamp
- func (x *CreateUserRequest) GetVerified() bool
- func (*CreateUserRequest) ProtoMessage()
- func (x *CreateUserRequest) ProtoReflect() protoreflect.Message
- func (x *CreateUserRequest) Reset()
- func (x *CreateUserRequest) String() string
- type DatabaseConfig
- func (*DatabaseConfig) Descriptor() ([]byte, []int)deprecated
- func (x *DatabaseConfig) GetMaxConnections() int32
- func (x *DatabaseConfig) GetTimeoutSeconds() int32
- func (x *DatabaseConfig) GetUrl() string
- func (*DatabaseConfig) ProtoMessage()
- func (x *DatabaseConfig) ProtoReflect() protoreflect.Message
- func (x *DatabaseConfig) Reset()
- func (x *DatabaseConfig) String() string
- type GetUserRequest
- func (*GetUserRequest) Descriptor() ([]byte, []int)deprecated
- func (x *GetUserRequest) GetFieldsFilter() string
- func (x *GetUserRequest) GetId() int64
- func (x *GetUserRequest) GetIncludeDetails() bool
- func (x *GetUserRequest) GetTimeoutMs() int32
- func (*GetUserRequest) ProtoMessage()
- func (x *GetUserRequest) ProtoReflect() protoreflect.Message
- func (x *GetUserRequest) Reset()
- func (x *GetUserRequest) String() string
- type LogLevel
- type MySQLBackend
- func (*MySQLBackend) Descriptor() ([]byte, []int)deprecated
- func (x *MySQLBackend) GetDatabase() string
- func (x *MySQLBackend) GetEnableSsl() bool
- func (x *MySQLBackend) GetHost() string
- func (x *MySQLBackend) GetPort() int32
- func (*MySQLBackend) ProtoMessage()
- func (x *MySQLBackend) ProtoReflect() protoreflect.Message
- func (x *MySQLBackend) Reset()
- func (x *MySQLBackend) String() string
- type PostgresBackend
- func (*PostgresBackend) Descriptor() ([]byte, []int)deprecated
- func (x *PostgresBackend) GetDatabase() string
- func (x *PostgresBackend) GetHost() string
- func (x *PostgresBackend) GetPort() int32
- func (*PostgresBackend) ProtoMessage()
- func (x *PostgresBackend) ProtoReflect() protoreflect.Message
- func (x *PostgresBackend) Reset()
- func (x *PostgresBackend) String() string
- type UnimplementedAdminServiceServer
- type UnimplementedUserServiceServer
- func (UnimplementedUserServiceServer) CreateUser(context.Context, *CreateUserRequest) (*UserResponse, error)
- func (UnimplementedUserServiceServer) GetUser(context.Context, *GetUserRequest) (*UserResponse, error)
- func (UnimplementedUserServiceServer) ListUsers(grpc.BidiStreamingServer[GetUserRequest, UserResponse]) error
- type UnsafeAdminServiceServer
- type UnsafeUserServiceServer
- type User
- func (*User) Descriptor() ([]byte, []int)deprecated
- func (x *User) GetAddress() *Address
- func (x *User) GetCreatedAt() *timestamppb.Timestamp
- func (x *User) GetEmail() string
- func (x *User) GetId() int64
- func (x *User) GetName() string
- func (*User) ProtoMessage()
- func (x *User) ProtoReflect() protoreflect.Message
- func (x *User) Reset()
- func (x *User) String() string
- type UserResponse
- func (*UserResponse) Descriptor() ([]byte, []int)deprecated
- func (x *UserResponse) GetMessage() string
- func (x *UserResponse) GetUser() *User
- func (*UserResponse) ProtoMessage()
- func (x *UserResponse) ProtoReflect() protoreflect.Message
- func (x *UserResponse) Reset()
- func (x *UserResponse) String() string
- type UserServiceClient
- type UserServiceConfig
- func (*UserServiceConfig) Descriptor() ([]byte, []int)deprecated
- func (x *UserServiceConfig) GetAllowedOrigins() []string
- func (x *UserServiceConfig) GetBackend() isUserServiceConfig_Backend
- func (x *UserServiceConfig) GetDatabase() *DatabaseConfig
- func (x *UserServiceConfig) GetDatabaseUrl() string
- func (x *UserServiceConfig) GetFeatureFlags() map[string]string
- func (x *UserServiceConfig) GetLogLevel() LogLevel
- func (x *UserServiceConfig) GetMaxConnections() int64
- func (x *UserServiceConfig) GetMysql() *MySQLBackend
- func (x *UserServiceConfig) GetPostgres() *PostgresBackend
- func (*UserServiceConfig) ProtoMessage()
- func (x *UserServiceConfig) ProtoReflect() protoreflect.Message
- func (x *UserServiceConfig) Reset()
- func (x *UserServiceConfig) String() string
- type UserServiceConfig_Mysql
- type UserServiceConfig_Postgres
- type UserServiceServer
- type UserService_ListUsersClient
- type UserService_ListUsersServer
Constants ¶
const ( UserService_GetUser_FullMethodName = "/example.UserService/GetUser" UserService_CreateUser_FullMethodName = "/example.UserService/CreateUser" UserService_ListUsers_FullMethodName = "/example.UserService/ListUsers" )
const (
AdminService_HealthCheck_FullMethodName = "/example.AdminService/HealthCheck"
)
Variables ¶
var ( LogLevel_name = map[int32]string{ 0: "LOG_LEVEL_UNSPECIFIED", 1: "DEBUG", 2: "INFO", 3: "WARN", 4: "ERROR", } LogLevel_value = map[string]int32{ "LOG_LEVEL_UNSPECIFIED": 0, "DEBUG": 1, "INFO": 2, "WARN": 3, "ERROR": 4, } )
Enum value maps for LogLevel.
var AdminService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "example.AdminService", HandlerType: (*AdminServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "HealthCheck", Handler: _AdminService_HealthCheck_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "examples/simple/example.proto", }
AdminService_ServiceDesc is the grpc.ServiceDesc for AdminService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
var File_examples_simple_example_proto protoreflect.FileDescriptor
var UserService_ServiceDesc = grpc.ServiceDesc{ ServiceName: "example.UserService", HandlerType: (*UserServiceServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "GetUser", Handler: _UserService_GetUser_Handler, }, { MethodName: "CreateUser", Handler: _UserService_CreateUser_Handler, }, }, Streams: []grpc.StreamDesc{ { StreamName: "ListUsers", Handler: _UserService_ListUsers_Handler, ServerStreams: true, ClientStreams: true, }, }, Metadata: "examples/simple/example.proto", }
UserService_ServiceDesc is the grpc.ServiceDesc for UserService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
Functions ¶
func AdminServiceCommand ¶
func AdminServiceCommand(ctx context.Context, implOrFactory interface{}, opts ...protocli.ServiceOption) *protocli.ServiceCLI
AdminServiceCommand creates a CLI for AdminService with options The implOrFactory parameter can be either a direct service implementation or a factory function
func AdminServiceCommandsFlat ¶
func AdminServiceCommandsFlat(ctx context.Context, implOrFactory interface{}, opts ...protocli.ServiceOption) []*v3.Command
AdminServiceCommandsFlat creates a flat command structure for AdminService (for single-service CLIs) This returns RPC commands directly at the root level instead of nested under a service command. The implOrFactory parameter can be either a direct service implementation or a factory function The returned slice includes all RPC commands plus a daemonize command for starting a gRPC server.
func RegisterAdminServiceServer ¶
func RegisterAdminServiceServer(s grpc.ServiceRegistrar, srv AdminServiceServer)
func RegisterUserServiceServer ¶
func RegisterUserServiceServer(s grpc.ServiceRegistrar, srv UserServiceServer)
func UserServiceCommand ¶
func UserServiceCommand(ctx context.Context, implOrFactory interface{}, opts ...protocli.ServiceOption) *protocli.ServiceCLI
UserServiceCommand creates a CLI for UserService with options The implOrFactory parameter can be either a direct service implementation or a factory function
func UserServiceCommandsFlat ¶
func UserServiceCommandsFlat(ctx context.Context, implOrFactory interface{}, opts ...protocli.ServiceOption) []*v3.Command
UserServiceCommandsFlat creates a flat command structure for UserService (for single-service CLIs) This returns RPC commands directly at the root level instead of nested under a service command. The implOrFactory parameter can be either a direct service implementation or a factory function The returned slice includes all RPC commands plus a daemonize command for starting a gRPC server.
Types ¶
type Address ¶
type Address struct {
Street string `protobuf:"bytes,1,opt,name=street,proto3" json:"street,omitempty"`
City string `protobuf:"bytes,2,opt,name=city,proto3" json:"city,omitempty"`
State string `protobuf:"bytes,3,opt,name=state,proto3" json:"state,omitempty"`
ZipCode string `protobuf:"bytes,4,opt,name=zip_code,json=zipCode,proto3" json:"zip_code,omitempty"`
Country string `protobuf:"bytes,5,opt,name=country,proto3" json:"country,omitempty"`
// contains filtered or unexported fields
}
Address is a nested message type for demonstrating recursive deserializers
func (*Address) Descriptor
deprecated
func (*Address) GetCountry ¶
func (*Address) GetZipCode ¶
func (*Address) ProtoMessage ¶
func (*Address) ProtoMessage()
func (*Address) ProtoReflect ¶
func (x *Address) ProtoReflect() protoreflect.Message
type AdminRequest ¶
type AdminRequest struct {
// contains filtered or unexported fields
}
Empty request for admin operations
func (*AdminRequest) Descriptor
deprecated
func (*AdminRequest) Descriptor() ([]byte, []int)
Deprecated: Use AdminRequest.ProtoReflect.Descriptor instead.
func (*AdminRequest) ProtoMessage ¶
func (*AdminRequest) ProtoMessage()
func (*AdminRequest) ProtoReflect ¶
func (x *AdminRequest) ProtoReflect() protoreflect.Message
func (*AdminRequest) Reset ¶
func (x *AdminRequest) Reset()
func (*AdminRequest) String ¶
func (x *AdminRequest) String() string
type AdminResponse ¶
type AdminResponse struct {
Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
Success bool `protobuf:"varint,2,opt,name=success,proto3" json:"success,omitempty"`
// contains filtered or unexported fields
}
Response for admin operations
func (*AdminResponse) Descriptor
deprecated
func (*AdminResponse) Descriptor() ([]byte, []int)
Deprecated: Use AdminResponse.ProtoReflect.Descriptor instead.
func (*AdminResponse) GetMessage ¶
func (x *AdminResponse) GetMessage() string
func (*AdminResponse) GetSuccess ¶
func (x *AdminResponse) GetSuccess() bool
func (*AdminResponse) ProtoMessage ¶
func (*AdminResponse) ProtoMessage()
func (*AdminResponse) ProtoReflect ¶
func (x *AdminResponse) ProtoReflect() protoreflect.Message
func (*AdminResponse) Reset ¶
func (x *AdminResponse) Reset()
func (*AdminResponse) String ¶
func (x *AdminResponse) String() string
type AdminServiceClient ¶
type AdminServiceClient interface {
// Health check endpoint
HealthCheck(ctx context.Context, in *AdminRequest, opts ...grpc.CallOption) (*AdminResponse, error)
}
AdminServiceClient is the client API for AdminService 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.
AdminService demonstrates service name override Without annotation, this would be "admin-service"
func NewAdminServiceClient ¶
func NewAdminServiceClient(cc grpc.ClientConnInterface) AdminServiceClient
type AdminServiceServer ¶
type AdminServiceServer interface {
// Health check endpoint
HealthCheck(context.Context, *AdminRequest) (*AdminResponse, error)
// contains filtered or unexported methods
}
AdminServiceServer is the server API for AdminService service. All implementations must embed UnimplementedAdminServiceServer for forward compatibility.
AdminService demonstrates service name override Without annotation, this would be "admin-service"
type CreateUserRequest ¶
type CreateUserRequest struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"`
Address *Address `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` // Nested address - demonstrates recursive deserializers
RegistrationDate *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=registration_date,json=registrationDate,proto3" json:"registration_date,omitempty"` // External type to test import qualification
// Field without annotation - demonstrates kebab-case default
PhoneNumber string `protobuf:"bytes,5,opt,name=phone_number,json=phoneNumber,proto3" json:"phone_number,omitempty"`
// Optional fields demonstrate explicit presence tracking
Nickname *string `protobuf:"bytes,6,opt,name=nickname,proto3,oneof" json:"nickname,omitempty"`
Age *int32 `protobuf:"varint,7,opt,name=age,proto3,oneof" json:"age,omitempty"`
Verified *bool `protobuf:"varint,8,opt,name=verified,proto3,oneof" json:"verified,omitempty"`
LogLevel *LogLevel `protobuf:"varint,9,opt,name=log_level,json=logLevel,proto3,enum=example.LogLevel,oneof" json:"log_level,omitempty"`
// contains filtered or unexported fields
}
Request to create a new user
func (*CreateUserRequest) Descriptor
deprecated
func (*CreateUserRequest) Descriptor() ([]byte, []int)
Deprecated: Use CreateUserRequest.ProtoReflect.Descriptor instead.
func (*CreateUserRequest) GetAddress ¶
func (x *CreateUserRequest) GetAddress() *Address
func (*CreateUserRequest) GetAge ¶
func (x *CreateUserRequest) GetAge() int32
func (*CreateUserRequest) GetEmail ¶
func (x *CreateUserRequest) GetEmail() string
func (*CreateUserRequest) GetLogLevel ¶
func (x *CreateUserRequest) GetLogLevel() LogLevel
func (*CreateUserRequest) GetName ¶
func (x *CreateUserRequest) GetName() string
func (*CreateUserRequest) GetNickname ¶
func (x *CreateUserRequest) GetNickname() string
func (*CreateUserRequest) GetPhoneNumber ¶
func (x *CreateUserRequest) GetPhoneNumber() string
func (*CreateUserRequest) GetRegistrationDate ¶
func (x *CreateUserRequest) GetRegistrationDate() *timestamppb.Timestamp
func (*CreateUserRequest) GetVerified ¶
func (x *CreateUserRequest) GetVerified() bool
func (*CreateUserRequest) ProtoMessage ¶
func (*CreateUserRequest) ProtoMessage()
func (*CreateUserRequest) ProtoReflect ¶
func (x *CreateUserRequest) ProtoReflect() protoreflect.Message
func (*CreateUserRequest) Reset ¶
func (x *CreateUserRequest) Reset()
func (*CreateUserRequest) String ¶
func (x *CreateUserRequest) String() string
type DatabaseConfig ¶
type DatabaseConfig struct {
Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"`
MaxConnections int32 `protobuf:"varint,2,opt,name=max_connections,json=maxConnections,proto3" json:"max_connections,omitempty"`
TimeoutSeconds int32 `protobuf:"varint,3,opt,name=timeout_seconds,json=timeoutSeconds,proto3" json:"timeout_seconds,omitempty"`
// contains filtered or unexported fields
}
DatabaseConfig is a nested configuration message
func (*DatabaseConfig) Descriptor
deprecated
func (*DatabaseConfig) Descriptor() ([]byte, []int)
Deprecated: Use DatabaseConfig.ProtoReflect.Descriptor instead.
func (*DatabaseConfig) GetMaxConnections ¶
func (x *DatabaseConfig) GetMaxConnections() int32
func (*DatabaseConfig) GetTimeoutSeconds ¶
func (x *DatabaseConfig) GetTimeoutSeconds() int32
func (*DatabaseConfig) GetUrl ¶
func (x *DatabaseConfig) GetUrl() string
func (*DatabaseConfig) ProtoMessage ¶
func (*DatabaseConfig) ProtoMessage()
func (*DatabaseConfig) ProtoReflect ¶
func (x *DatabaseConfig) ProtoReflect() protoreflect.Message
func (*DatabaseConfig) Reset ¶
func (x *DatabaseConfig) Reset()
func (*DatabaseConfig) String ¶
func (x *DatabaseConfig) String() string
type GetUserRequest ¶
type GetUserRequest struct {
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
// Field with partial annotation - demonstrates name defaults to kebab-case
IncludeDetails bool `protobuf:"varint,2,opt,name=include_details,json=includeDetails,proto3" json:"include_details,omitempty"`
// Optional fields demonstrate explicit presence tracking in proto3
FieldsFilter *string `protobuf:"bytes,3,opt,name=fields_filter,json=fieldsFilter,proto3,oneof" json:"fields_filter,omitempty"`
TimeoutMs *int32 `protobuf:"varint,4,opt,name=timeout_ms,json=timeoutMs,proto3,oneof" json:"timeout_ms,omitempty"`
// contains filtered or unexported fields
}
Request to get a user by ID
func (*GetUserRequest) Descriptor
deprecated
func (*GetUserRequest) Descriptor() ([]byte, []int)
Deprecated: Use GetUserRequest.ProtoReflect.Descriptor instead.
func (*GetUserRequest) GetFieldsFilter ¶
func (x *GetUserRequest) GetFieldsFilter() string
func (*GetUserRequest) GetId ¶
func (x *GetUserRequest) GetId() int64
func (*GetUserRequest) GetIncludeDetails ¶
func (x *GetUserRequest) GetIncludeDetails() bool
func (*GetUserRequest) GetTimeoutMs ¶
func (x *GetUserRequest) GetTimeoutMs() int32
func (*GetUserRequest) ProtoMessage ¶
func (*GetUserRequest) ProtoMessage()
func (*GetUserRequest) ProtoReflect ¶
func (x *GetUserRequest) ProtoReflect() protoreflect.Message
func (*GetUserRequest) Reset ¶
func (x *GetUserRequest) Reset()
func (*GetUserRequest) String ¶
func (x *GetUserRequest) String() string
type LogLevel ¶
type LogLevel int32
LogLevel enum for configuration
func (LogLevel) Descriptor ¶
func (LogLevel) Descriptor() protoreflect.EnumDescriptor
func (LogLevel) EnumDescriptor
deprecated
func (LogLevel) Number ¶
func (x LogLevel) Number() protoreflect.EnumNumber
func (LogLevel) Type ¶
func (LogLevel) Type() protoreflect.EnumType
type MySQLBackend ¶
type MySQLBackend struct {
Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"`
Port int32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"`
Database string `protobuf:"bytes,3,opt,name=database,proto3" json:"database,omitempty"`
EnableSsl bool `protobuf:"varint,4,opt,name=enable_ssl,json=enableSsl,proto3" json:"enable_ssl,omitempty"`
// contains filtered or unexported fields
}
MySQLBackend configuration
func (*MySQLBackend) Descriptor
deprecated
func (*MySQLBackend) Descriptor() ([]byte, []int)
Deprecated: Use MySQLBackend.ProtoReflect.Descriptor instead.
func (*MySQLBackend) GetDatabase ¶
func (x *MySQLBackend) GetDatabase() string
func (*MySQLBackend) GetEnableSsl ¶
func (x *MySQLBackend) GetEnableSsl() bool
func (*MySQLBackend) GetHost ¶
func (x *MySQLBackend) GetHost() string
func (*MySQLBackend) GetPort ¶
func (x *MySQLBackend) GetPort() int32
func (*MySQLBackend) ProtoMessage ¶
func (*MySQLBackend) ProtoMessage()
func (*MySQLBackend) ProtoReflect ¶
func (x *MySQLBackend) ProtoReflect() protoreflect.Message
func (*MySQLBackend) Reset ¶
func (x *MySQLBackend) Reset()
func (*MySQLBackend) String ¶
func (x *MySQLBackend) String() string
type PostgresBackend ¶
type PostgresBackend struct {
Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"`
Port int32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"`
Database string `protobuf:"bytes,3,opt,name=database,proto3" json:"database,omitempty"`
// contains filtered or unexported fields
}
PostgresBackend configuration
func (*PostgresBackend) Descriptor
deprecated
func (*PostgresBackend) Descriptor() ([]byte, []int)
Deprecated: Use PostgresBackend.ProtoReflect.Descriptor instead.
func (*PostgresBackend) GetDatabase ¶
func (x *PostgresBackend) GetDatabase() string
func (*PostgresBackend) GetHost ¶
func (x *PostgresBackend) GetHost() string
func (*PostgresBackend) GetPort ¶
func (x *PostgresBackend) GetPort() int32
func (*PostgresBackend) ProtoMessage ¶
func (*PostgresBackend) ProtoMessage()
func (*PostgresBackend) ProtoReflect ¶
func (x *PostgresBackend) ProtoReflect() protoreflect.Message
func (*PostgresBackend) Reset ¶
func (x *PostgresBackend) Reset()
func (*PostgresBackend) String ¶
func (x *PostgresBackend) String() string
type UnimplementedAdminServiceServer ¶
type UnimplementedAdminServiceServer struct{}
UnimplementedAdminServiceServer 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.
func (UnimplementedAdminServiceServer) HealthCheck ¶
func (UnimplementedAdminServiceServer) HealthCheck(context.Context, *AdminRequest) (*AdminResponse, error)
type UnimplementedUserServiceServer ¶
type UnimplementedUserServiceServer struct{}
UnimplementedUserServiceServer 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.
func (UnimplementedUserServiceServer) CreateUser ¶
func (UnimplementedUserServiceServer) CreateUser(context.Context, *CreateUserRequest) (*UserResponse, error)
func (UnimplementedUserServiceServer) GetUser ¶
func (UnimplementedUserServiceServer) GetUser(context.Context, *GetUserRequest) (*UserResponse, error)
func (UnimplementedUserServiceServer) ListUsers ¶
func (UnimplementedUserServiceServer) ListUsers(grpc.BidiStreamingServer[GetUserRequest, UserResponse]) error
type UnsafeAdminServiceServer ¶
type UnsafeAdminServiceServer interface {
// contains filtered or unexported methods
}
UnsafeAdminServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to AdminServiceServer will result in compilation errors.
type UnsafeUserServiceServer ¶
type UnsafeUserServiceServer interface {
// contains filtered or unexported methods
}
UnsafeUserServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to UserServiceServer will result in compilation errors.
type User ¶
type User struct {
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"`
Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
CreatedAt *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` // External type to test import qualification
Address *Address `protobuf:"bytes,5,opt,name=address,proto3" json:"address,omitempty"` // Nested address field
// contains filtered or unexported fields
}
User message definition
func (*User) Descriptor
deprecated
func (*User) GetAddress ¶
func (*User) GetCreatedAt ¶
func (x *User) GetCreatedAt() *timestamppb.Timestamp
func (*User) ProtoMessage ¶
func (*User) ProtoMessage()
func (*User) ProtoReflect ¶
func (x *User) ProtoReflect() protoreflect.Message
type UserResponse ¶
type UserResponse struct {
User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
// contains filtered or unexported fields
}
Response containing a user
func (*UserResponse) Descriptor
deprecated
func (*UserResponse) Descriptor() ([]byte, []int)
Deprecated: Use UserResponse.ProtoReflect.Descriptor instead.
func (*UserResponse) GetMessage ¶
func (x *UserResponse) GetMessage() string
func (*UserResponse) GetUser ¶
func (x *UserResponse) GetUser() *User
func (*UserResponse) ProtoMessage ¶
func (*UserResponse) ProtoMessage()
func (*UserResponse) ProtoReflect ¶
func (x *UserResponse) ProtoReflect() protoreflect.Message
func (*UserResponse) Reset ¶
func (x *UserResponse) Reset()
func (*UserResponse) String ¶
func (x *UserResponse) String() string
type UserServiceClient ¶
type UserServiceClient interface {
// GetUser retrieves a user by ID
GetUser(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*UserResponse, error)
// CreateUser creates a new user
CreateUser(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*UserResponse, error)
// ListUsers streams all users
ListUsers(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[GetUserRequest, UserResponse], error)
}
UserServiceClient is the client API for UserService 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.
UserService defines gRPC service methods
func NewUserServiceClient ¶
func NewUserServiceClient(cc grpc.ClientConnInterface) UserServiceClient
type UserServiceConfig ¶
type UserServiceConfig struct {
DatabaseUrl string `protobuf:"bytes,1,opt,name=database_url,json=databaseUrl,proto3" json:"database_url,omitempty"`
MaxConnections int64 `protobuf:"varint,2,opt,name=max_connections,json=maxConnections,proto3" json:"max_connections,omitempty"`
// Nested message field
Database *DatabaseConfig `protobuf:"bytes,3,opt,name=database,proto3" json:"database,omitempty"`
// Enum field
LogLevel LogLevel `protobuf:"varint,4,opt,name=log_level,json=logLevel,proto3,enum=example.LogLevel" json:"log_level,omitempty"`
// Repeated field
AllowedOrigins []string `protobuf:"bytes,5,rep,name=allowed_origins,json=allowedOrigins,proto3" json:"allowed_origins,omitempty"`
// Map field
FeatureFlags map[string]string `` /* 171-byte string literal not displayed */
// Oneof (union type)
//
// Types that are valid to be assigned to Backend:
//
// *UserServiceConfig_Postgres
// *UserServiceConfig_Mysql
Backend isUserServiceConfig_Backend `protobuf_oneof:"backend"`
// contains filtered or unexported fields
}
UserServiceConfig defines configuration for UserService
func (*UserServiceConfig) Descriptor
deprecated
func (*UserServiceConfig) Descriptor() ([]byte, []int)
Deprecated: Use UserServiceConfig.ProtoReflect.Descriptor instead.
func (*UserServiceConfig) GetAllowedOrigins ¶
func (x *UserServiceConfig) GetAllowedOrigins() []string
func (*UserServiceConfig) GetBackend ¶
func (x *UserServiceConfig) GetBackend() isUserServiceConfig_Backend
func (*UserServiceConfig) GetDatabase ¶
func (x *UserServiceConfig) GetDatabase() *DatabaseConfig
func (*UserServiceConfig) GetDatabaseUrl ¶
func (x *UserServiceConfig) GetDatabaseUrl() string
func (*UserServiceConfig) GetFeatureFlags ¶
func (x *UserServiceConfig) GetFeatureFlags() map[string]string
func (*UserServiceConfig) GetLogLevel ¶
func (x *UserServiceConfig) GetLogLevel() LogLevel
func (*UserServiceConfig) GetMaxConnections ¶
func (x *UserServiceConfig) GetMaxConnections() int64
func (*UserServiceConfig) GetMysql ¶
func (x *UserServiceConfig) GetMysql() *MySQLBackend
func (*UserServiceConfig) GetPostgres ¶
func (x *UserServiceConfig) GetPostgres() *PostgresBackend
func (*UserServiceConfig) ProtoMessage ¶
func (*UserServiceConfig) ProtoMessage()
func (*UserServiceConfig) ProtoReflect ¶
func (x *UserServiceConfig) ProtoReflect() protoreflect.Message
func (*UserServiceConfig) Reset ¶
func (x *UserServiceConfig) Reset()
func (*UserServiceConfig) String ¶
func (x *UserServiceConfig) String() string
type UserServiceConfig_Mysql ¶
type UserServiceConfig_Mysql struct {
Mysql *MySQLBackend `protobuf:"bytes,8,opt,name=mysql,proto3,oneof"`
}
type UserServiceConfig_Postgres ¶
type UserServiceConfig_Postgres struct {
Postgres *PostgresBackend `protobuf:"bytes,7,opt,name=postgres,proto3,oneof"`
}
type UserServiceServer ¶
type UserServiceServer interface {
// GetUser retrieves a user by ID
GetUser(context.Context, *GetUserRequest) (*UserResponse, error)
// CreateUser creates a new user
CreateUser(context.Context, *CreateUserRequest) (*UserResponse, error)
// ListUsers streams all users
ListUsers(grpc.BidiStreamingServer[GetUserRequest, UserResponse]) error
// contains filtered or unexported methods
}
UserServiceServer is the server API for UserService service. All implementations must embed UnimplementedUserServiceServer for forward compatibility.
UserService defines gRPC service methods
type UserService_ListUsersClient ¶
type UserService_ListUsersClient = grpc.BidiStreamingClient[GetUserRequest, UserResponse]
This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type UserService_ListUsersServer ¶
type UserService_ListUsersServer = grpc.BidiStreamingServer[GetUserRequest, UserResponse]
This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.