example

package
v0.0.0-...-6236971 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2021 License: BSD-3-Clause Imports: 21 Imported by: 8

Documentation

Overview

Package example is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthExample        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowExample          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupExample = fmt.Errorf("proto: unexpected end of group")
)
View Source
var Role_name = map[int32]string{
	0: "GUEST",
	1: "MEMBER",
	2: "ADMIN",
}
View Source
var Role_value = map[string]int32{
	"GUEST":  0,
	"MEMBER": 1,
	"ADMIN":  2,
}

Functions

func RegisterUserServiceHandler

func RegisterUserServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterUserServiceHandler registers the http handlers for service UserService to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterUserServiceHandlerClient

func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UserServiceClient) error

RegisterUserServiceHandlerClient registers the http handlers for service UserService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "UserServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "UserServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "UserServiceClient" to call the correct interceptors.

func RegisterUserServiceHandlerFromEndpoint

func RegisterUserServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterUserServiceHandlerFromEndpoint is same as RegisterUserServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterUserServiceHandlerServer

func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UserServiceServer) error

RegisterUserServiceHandlerServer registers the http handlers for service UserService to "mux". UnaryRPC :call UserServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.

func RegisterUserServiceServer

func RegisterUserServiceServer(s *grpc.Server, srv UserServiceServer)

Types

type ListUsersRequest

type ListUsersRequest struct {
	// Only list users created after this timestamp
	CreatedSince *time.Time `protobuf:"bytes,1,opt,name=created_since,json=createdSince,proto3,stdtime" json:"created_since,omitempty"`
	// Only list users older than this Duration
	OlderThan            *time.Duration `protobuf:"bytes,2,opt,name=older_than,json=olderThan,proto3,stdduration" json:"older_than,omitempty"`
	XXX_NoUnkeyedLiteral struct{}       `json:"-"`
	XXX_unrecognized     []byte         `json:"-"`
	XXX_sizecache        int32          `json:"-"`
}

func (*ListUsersRequest) Descriptor

func (*ListUsersRequest) Descriptor() ([]byte, []int)

func (*ListUsersRequest) GetCreatedSince

func (m *ListUsersRequest) GetCreatedSince() *time.Time

func (*ListUsersRequest) GetOlderThan

func (m *ListUsersRequest) GetOlderThan() *time.Duration

func (*ListUsersRequest) Marshal

func (m *ListUsersRequest) Marshal() (dAtA []byte, err error)

func (*ListUsersRequest) MarshalTo

func (m *ListUsersRequest) MarshalTo(dAtA []byte) (int, error)

func (*ListUsersRequest) MarshalToSizedBuffer

func (m *ListUsersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*ListUsersRequest) ProtoMessage

func (*ListUsersRequest) ProtoMessage()

func (*ListUsersRequest) Reset

func (m *ListUsersRequest) Reset()

func (*ListUsersRequest) Size

func (m *ListUsersRequest) Size() (n int)

func (*ListUsersRequest) String

func (m *ListUsersRequest) String() string

func (*ListUsersRequest) Unmarshal

func (m *ListUsersRequest) Unmarshal(dAtA []byte) error

func (*ListUsersRequest) Validate

func (this *ListUsersRequest) Validate() error

func (*ListUsersRequest) XXX_DiscardUnknown

func (m *ListUsersRequest) XXX_DiscardUnknown()

func (*ListUsersRequest) XXX_Marshal

func (m *ListUsersRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ListUsersRequest) XXX_Merge

func (m *ListUsersRequest) XXX_Merge(src proto.Message)

func (*ListUsersRequest) XXX_MessageName

func (*ListUsersRequest) XXX_MessageName() string

func (*ListUsersRequest) XXX_Size

func (m *ListUsersRequest) XXX_Size() int

func (*ListUsersRequest) XXX_Unmarshal

func (m *ListUsersRequest) XXX_Unmarshal(b []byte) error

type Role

type Role int32
const (
	Role_GUEST  Role = 0
	Role_MEMBER Role = 1
	Role_ADMIN  Role = 2
)

func (Role) EnumDescriptor

func (Role) EnumDescriptor() ([]byte, []int)

func (Role) String

func (x Role) String() string

type UnimplementedUserServiceServer

type UnimplementedUserServiceServer struct {
}

UnimplementedUserServiceServer can be embedded to have forward compatible implementations.

func (*UnimplementedUserServiceServer) AddUser

func (*UnimplementedUserServiceServer) ListUsers

func (*UnimplementedUserServiceServer) ListUsersByRole

func (*UnimplementedUserServiceServer) UpdateUser

type UpdateUserRequest

type UpdateUserRequest struct {
	// The user resource which replaces the resource on the server.
	User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"`
	// The update mask applies to the resource. For the `FieldMask` definition,
	// see https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask
	UpdateMask           *types.FieldMask `protobuf:"bytes,2,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"`
	XXX_NoUnkeyedLiteral struct{}         `json:"-"`
	XXX_unrecognized     []byte           `json:"-"`
	XXX_sizecache        int32            `json:"-"`
}

func (*UpdateUserRequest) Descriptor

func (*UpdateUserRequest) Descriptor() ([]byte, []int)

func (*UpdateUserRequest) GetUpdateMask

func (m *UpdateUserRequest) GetUpdateMask() *types.FieldMask

func (*UpdateUserRequest) GetUser

func (m *UpdateUserRequest) GetUser() *User

func (*UpdateUserRequest) Marshal

func (m *UpdateUserRequest) Marshal() (dAtA []byte, err error)

func (*UpdateUserRequest) MarshalTo

func (m *UpdateUserRequest) MarshalTo(dAtA []byte) (int, error)

func (*UpdateUserRequest) MarshalToSizedBuffer

func (m *UpdateUserRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*UpdateUserRequest) ProtoMessage

func (*UpdateUserRequest) ProtoMessage()

func (*UpdateUserRequest) Reset

func (m *UpdateUserRequest) Reset()

func (*UpdateUserRequest) Size

func (m *UpdateUserRequest) Size() (n int)

func (*UpdateUserRequest) String

func (m *UpdateUserRequest) String() string

func (*UpdateUserRequest) Unmarshal

func (m *UpdateUserRequest) Unmarshal(dAtA []byte) error

func (*UpdateUserRequest) Validate

func (this *UpdateUserRequest) Validate() error

func (*UpdateUserRequest) XXX_DiscardUnknown

func (m *UpdateUserRequest) XXX_DiscardUnknown()

func (*UpdateUserRequest) XXX_Marshal

func (m *UpdateUserRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UpdateUserRequest) XXX_Merge

func (m *UpdateUserRequest) XXX_Merge(src proto.Message)

func (*UpdateUserRequest) XXX_MessageName

func (*UpdateUserRequest) XXX_MessageName() string

func (*UpdateUserRequest) XXX_Size

func (m *UpdateUserRequest) XXX_Size() int

func (*UpdateUserRequest) XXX_Unmarshal

func (m *UpdateUserRequest) XXX_Unmarshal(b []byte) error

type User

type User struct {
	ID                   uint32     `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
	Role                 Role       `protobuf:"varint,2,opt,name=role,proto3,enum=example.Role" json:"role,omitempty"`
	CreateDate           *time.Time `protobuf:"bytes,3,opt,name=create_date,json=createDate,proto3,stdtime" json:"create_date,omitempty"`
	XXX_NoUnkeyedLiteral struct{}   `json:"-"`
	XXX_unrecognized     []byte     `json:"-"`
	XXX_sizecache        int32      `json:"-"`
}

func (*User) Descriptor

func (*User) Descriptor() ([]byte, []int)

func (*User) GetCreateDate

func (m *User) GetCreateDate() *time.Time

func (*User) GetID

func (m *User) GetID() uint32

func (*User) GetRole

func (m *User) GetRole() Role

func (*User) Marshal

func (m *User) Marshal() (dAtA []byte, err error)

func (*User) MarshalTo

func (m *User) MarshalTo(dAtA []byte) (int, error)

func (*User) MarshalToSizedBuffer

func (m *User) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*User) ProtoMessage

func (*User) ProtoMessage()

func (*User) Reset

func (m *User) Reset()

func (*User) Size

func (m *User) Size() (n int)

func (*User) String

func (m *User) String() string

func (*User) Unmarshal

func (m *User) Unmarshal(dAtA []byte) error

func (*User) Validate

func (this *User) Validate() error

func (*User) XXX_DiscardUnknown

func (m *User) XXX_DiscardUnknown()

func (*User) XXX_Marshal

func (m *User) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*User) XXX_Merge

func (m *User) XXX_Merge(src proto.Message)

func (*User) XXX_MessageName

func (*User) XXX_MessageName() string

func (*User) XXX_Size

func (m *User) XXX_Size() int

func (*User) XXX_Unmarshal

func (m *User) XXX_Unmarshal(b []byte) error

type UserRole

type UserRole struct {
	Role                 Role     `protobuf:"varint,1,opt,name=role,proto3,enum=example.Role" json:"role,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*UserRole) Descriptor

func (*UserRole) Descriptor() ([]byte, []int)

func (*UserRole) GetRole

func (m *UserRole) GetRole() Role

func (*UserRole) Marshal

func (m *UserRole) Marshal() (dAtA []byte, err error)

func (*UserRole) MarshalTo

func (m *UserRole) MarshalTo(dAtA []byte) (int, error)

func (*UserRole) MarshalToSizedBuffer

func (m *UserRole) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*UserRole) ProtoMessage

func (*UserRole) ProtoMessage()

func (*UserRole) Reset

func (m *UserRole) Reset()

func (*UserRole) Size

func (m *UserRole) Size() (n int)

func (*UserRole) String

func (m *UserRole) String() string

func (*UserRole) Unmarshal

func (m *UserRole) Unmarshal(dAtA []byte) error

func (*UserRole) Validate

func (this *UserRole) Validate() error

func (*UserRole) XXX_DiscardUnknown

func (m *UserRole) XXX_DiscardUnknown()

func (*UserRole) XXX_Marshal

func (m *UserRole) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*UserRole) XXX_Merge

func (m *UserRole) XXX_Merge(src proto.Message)

func (*UserRole) XXX_MessageName

func (*UserRole) XXX_MessageName() string

func (*UserRole) XXX_Size

func (m *UserRole) XXX_Size() int

func (*UserRole) XXX_Unmarshal

func (m *UserRole) XXX_Unmarshal(b []byte) error

type UserServiceClient

type UserServiceClient interface {
	AddUser(ctx context.Context, in *User, opts ...grpc.CallOption) (*types.Empty, error)
	ListUsers(ctx context.Context, in *ListUsersRequest, opts ...grpc.CallOption) (UserService_ListUsersClient, error)
	ListUsersByRole(ctx context.Context, in *UserRole, opts ...grpc.CallOption) (UserService_ListUsersByRoleClient, error)
	UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...grpc.CallOption) (*User, error)
}

UserServiceClient is the client API for UserService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewUserServiceClient

func NewUserServiceClient(cc *grpc.ClientConn) UserServiceClient

type UserServiceServer

type UserServiceServer interface {
	AddUser(context.Context, *User) (*types.Empty, error)
	ListUsers(*ListUsersRequest, UserService_ListUsersServer) error
	ListUsersByRole(*UserRole, UserService_ListUsersByRoleServer) error
	UpdateUser(context.Context, *UpdateUserRequest) (*User, error)
}

UserServiceServer is the server API for UserService service.

type UserService_ListUsersByRoleClient

type UserService_ListUsersByRoleClient interface {
	Recv() (*User, error)
	grpc.ClientStream
}

type UserService_ListUsersByRoleServer

type UserService_ListUsersByRoleServer interface {
	Send(*User) error
	grpc.ServerStream
}

type UserService_ListUsersClient

type UserService_ListUsersClient interface {
	Recv() (*User, error)
	grpc.ClientStream
}

type UserService_ListUsersServer

type UserService_ListUsersServer interface {
	Send(*User) error
	grpc.ServerStream
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL