redditv1

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package redditv1 is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var File_protos_reddit_reddit_proto protoreflect.FileDescriptor
View Source
var RedditService_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "reddit.v1.RedditService",
	HandlerType: (*RedditServiceServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "GetSubredditMostUps",
			Handler:    _RedditService_GetSubredditMostUps_Handler,
		},
		{
			MethodName: "GetSubredditAuthorPosts",
			Handler:    _RedditService_GetSubredditAuthorPosts_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "protos/reddit/reddit.proto",
}

RedditService_ServiceDesc is the grpc.ServiceDesc for RedditService service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterRedditServiceHandler

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

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

func RegisterRedditServiceHandlerClient

func RegisterRedditServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client RedditServiceClient) error

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

func RegisterRedditServiceHandlerFromEndpoint

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

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

func RegisterRedditServiceHandlerServer

func RegisterRedditServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server RedditServiceServer) error

RegisterRedditServiceHandlerServer registers the http handlers for service RedditService to "mux". UnaryRPC :call RedditServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterRedditServiceHandlerFromEndpoint instead.

func RegisterRedditServiceServer

func RegisterRedditServiceServer(s grpc.ServiceRegistrar, srv RedditServiceServer)

Types

type GetSubredditAuthorPostsRequest

type GetSubredditAuthorPostsRequest struct {

	// the subreddit name, which does not include the `/r`
	Subreddit string `protobuf:"bytes,1,opt,name=subreddit,proto3" json:"subreddit,omitempty"`
	// the limit of the response, optional
	Limit int32 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"`
	// contains filtered or unexported fields
}

func (*GetSubredditAuthorPostsRequest) Descriptor deprecated

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

Deprecated: Use GetSubredditAuthorPostsRequest.ProtoReflect.Descriptor instead.

func (*GetSubredditAuthorPostsRequest) GetLimit

func (x *GetSubredditAuthorPostsRequest) GetLimit() int32

func (*GetSubredditAuthorPostsRequest) GetSubreddit

func (x *GetSubredditAuthorPostsRequest) GetSubreddit() string

func (*GetSubredditAuthorPostsRequest) ProtoMessage

func (*GetSubredditAuthorPostsRequest) ProtoMessage()

func (*GetSubredditAuthorPostsRequest) ProtoReflect

func (*GetSubredditAuthorPostsRequest) Reset

func (x *GetSubredditAuthorPostsRequest) Reset()

func (*GetSubredditAuthorPostsRequest) String

type GetSubredditAuthorPostsResponse

type GetSubredditAuthorPostsResponse struct {

	// a list of authors with the number of post in the subreddit
	AuthorPosts []*SubredditPost `protobuf:"bytes,1,rep,name=author_posts,json=authorPosts,proto3" json:"author_posts,omitempty"`
	// contains filtered or unexported fields
}

func (*GetSubredditAuthorPostsResponse) Descriptor deprecated

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

Deprecated: Use GetSubredditAuthorPostsResponse.ProtoReflect.Descriptor instead.

func (*GetSubredditAuthorPostsResponse) GetAuthorPosts

func (x *GetSubredditAuthorPostsResponse) GetAuthorPosts() []*SubredditPost

func (*GetSubredditAuthorPostsResponse) ProtoMessage

func (*GetSubredditAuthorPostsResponse) ProtoMessage()

func (*GetSubredditAuthorPostsResponse) ProtoReflect

func (*GetSubredditAuthorPostsResponse) Reset

func (*GetSubredditAuthorPostsResponse) String

type GetSubredditMostUpsRequest

type GetSubredditMostUpsRequest struct {

	// the subreddit name, which does not include the `/r`
	Subreddit string `protobuf:"bytes,1,opt,name=subreddit,proto3" json:"subreddit,omitempty"`
	// the limit of the response, optional
	Limit int32 `protobuf:"varint,2,opt,name=limit,proto3" json:"limit,omitempty"`
	// contains filtered or unexported fields
}

func (*GetSubredditMostUpsRequest) Descriptor deprecated

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

Deprecated: Use GetSubredditMostUpsRequest.ProtoReflect.Descriptor instead.

func (*GetSubredditMostUpsRequest) GetLimit

func (x *GetSubredditMostUpsRequest) GetLimit() int32

func (*GetSubredditMostUpsRequest) GetSubreddit

func (x *GetSubredditMostUpsRequest) GetSubreddit() string

func (*GetSubredditMostUpsRequest) ProtoMessage

func (*GetSubredditMostUpsRequest) ProtoMessage()

func (*GetSubredditMostUpsRequest) ProtoReflect

func (*GetSubredditMostUpsRequest) Reset

func (x *GetSubredditMostUpsRequest) Reset()

func (*GetSubredditMostUpsRequest) String

func (x *GetSubredditMostUpsRequest) String() string

type GetSubredditMostUpsResponse

type GetSubredditMostUpsResponse struct {

	// a list of subreddit posts that have the most up votes
	SubredditPosts []*SubredditData `protobuf:"bytes,1,rep,name=subreddit_posts,json=subredditPosts,proto3" json:"subreddit_posts,omitempty"`
	// contains filtered or unexported fields
}

func (*GetSubredditMostUpsResponse) Descriptor deprecated

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

Deprecated: Use GetSubredditMostUpsResponse.ProtoReflect.Descriptor instead.

func (*GetSubredditMostUpsResponse) GetSubredditPosts

func (x *GetSubredditMostUpsResponse) GetSubredditPosts() []*SubredditData

func (*GetSubredditMostUpsResponse) ProtoMessage

func (*GetSubredditMostUpsResponse) ProtoMessage()

func (*GetSubredditMostUpsResponse) ProtoReflect

func (*GetSubredditMostUpsResponse) Reset

func (x *GetSubredditMostUpsResponse) Reset()

func (*GetSubredditMostUpsResponse) String

func (x *GetSubredditMostUpsResponse) String() string

type RedditServiceClient

type RedditServiceClient interface {
	// GetSubredditMostUps retrives the subreddit posts that have the most ups (up votes)
	//
	// # Responses:
	// | HTTP Status | gRPC Code | Description |
	// | --- | --- | --- |
	// | 200 | `codes.OK` | subreddit posts with the most ups |
	// | 400 | `codes.InvalidArgument` | `subreddit` parameters is empty |
	// | 500 | `codes.Internal` | service was unable to process the request do to an interanl error |
	GetSubredditMostUps(ctx context.Context, in *GetSubredditMostUpsRequest, opts ...grpc.CallOption) (*GetSubredditMostUpsResponse, error)
	// GetSubredditAuthorPosts retrives the authors that have the most posts for a subreddit
	//
	// # Responses:
	// | HTTP Status | gRPC Code | Description |
	// | --- | --- | --- |
	// | 200 | `codes.OK` | subreddit author's posts |
	// | 400 | `codes.InvalidArgument` | `subreddit` parameters is empty |
	// | 500 | `codes.Internal` | service was unable to process the request do to an interanl error |
	GetSubredditAuthorPosts(ctx context.Context, in *GetSubredditAuthorPostsRequest, opts ...grpc.CallOption) (*GetSubredditAuthorPostsResponse, error)
}

RedditServiceClient is the client API for RedditService 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 RedditServiceServer

type RedditServiceServer interface {
	// GetSubredditMostUps retrives the subreddit posts that have the most ups (up votes)
	//
	// # Responses:
	// | HTTP Status | gRPC Code | Description |
	// | --- | --- | --- |
	// | 200 | `codes.OK` | subreddit posts with the most ups |
	// | 400 | `codes.InvalidArgument` | `subreddit` parameters is empty |
	// | 500 | `codes.Internal` | service was unable to process the request do to an interanl error |
	GetSubredditMostUps(context.Context, *GetSubredditMostUpsRequest) (*GetSubredditMostUpsResponse, error)
	// GetSubredditAuthorPosts retrives the authors that have the most posts for a subreddit
	//
	// # Responses:
	// | HTTP Status | gRPC Code | Description |
	// | --- | --- | --- |
	// | 200 | `codes.OK` | subreddit author's posts |
	// | 400 | `codes.InvalidArgument` | `subreddit` parameters is empty |
	// | 500 | `codes.Internal` | service was unable to process the request do to an interanl error |
	GetSubredditAuthorPosts(context.Context, *GetSubredditAuthorPostsRequest) (*GetSubredditAuthorPostsResponse, error)
}

RedditServiceServer is the server API for RedditService service. All implementations should embed UnimplementedRedditServiceServer for forward compatibility

type SubredditData

type SubredditData struct {

	// the title of the subreddit post
	Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
	// number of down votes
	Downs int32 `protobuf:"varint,2,opt,name=downs,proto3" json:"downs,omitempty"`
	// the upvote rator
	UpvoteRatio float32 `protobuf:"fixed32,3,opt,name=upvote_ratio,json=upvoteRatio,proto3" json:"upvote_ratio,omitempty"`
	// number of up votes
	Ups int32 `protobuf:"varint,4,opt,name=ups,proto3" json:"ups,omitempty"`
	// total number of awards reeceived
	TotalAwardsReceived int32 `protobuf:"varint,5,opt,name=total_awards_received,json=totalAwardsReceived,proto3" json:"total_awards_received,omitempty"`
	// name of the subredit
	Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"`
	// subreddit name like funny
	Subreddit string `protobuf:"bytes,7,opt,name=subreddit,proto3" json:"subreddit,omitempty"`
	// id of the subreddit
	Id string `protobuf:"bytes,8,opt,name=id,proto3" json:"id,omitempty"`
	// author username
	Author string `protobuf:"bytes,9,opt,name=author,proto3" json:"author,omitempty"`
	// author id
	AuthorFullname string `protobuf:"bytes,10,opt,name=author_fullname,json=authorFullname,proto3" json:"author_fullname,omitempty"`
	// contains filtered or unexported fields
}

func (*SubredditData) Descriptor deprecated

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

Deprecated: Use SubredditData.ProtoReflect.Descriptor instead.

func (*SubredditData) GetAuthor

func (x *SubredditData) GetAuthor() string

func (*SubredditData) GetAuthorFullname

func (x *SubredditData) GetAuthorFullname() string

func (*SubredditData) GetDowns

func (x *SubredditData) GetDowns() int32

func (*SubredditData) GetId

func (x *SubredditData) GetId() string

func (*SubredditData) GetName

func (x *SubredditData) GetName() string

func (*SubredditData) GetSubreddit

func (x *SubredditData) GetSubreddit() string

func (*SubredditData) GetTitle

func (x *SubredditData) GetTitle() string

func (*SubredditData) GetTotalAwardsReceived

func (x *SubredditData) GetTotalAwardsReceived() int32

func (*SubredditData) GetUps

func (x *SubredditData) GetUps() int32

func (*SubredditData) GetUpvoteRatio

func (x *SubredditData) GetUpvoteRatio() float32

func (*SubredditData) ProtoMessage

func (*SubredditData) ProtoMessage()

func (*SubredditData) ProtoReflect

func (x *SubredditData) ProtoReflect() protoreflect.Message

func (*SubredditData) Reset

func (x *SubredditData) Reset()

func (*SubredditData) String

func (x *SubredditData) String() string

type SubredditPost

type SubredditPost struct {

	// author id
	AuthorFullname string `protobuf:"bytes,1,opt,name=author_fullname,json=authorFullname,proto3" json:"author_fullname,omitempty"`
	// author username
	Author string `protobuf:"bytes,2,opt,name=author,proto3" json:"author,omitempty"`
	// number of posts
	Posts int32 `protobuf:"varint,3,opt,name=posts,proto3" json:"posts,omitempty"`
	// contains filtered or unexported fields
}

func (*SubredditPost) Descriptor deprecated

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

Deprecated: Use SubredditPost.ProtoReflect.Descriptor instead.

func (*SubredditPost) GetAuthor

func (x *SubredditPost) GetAuthor() string

func (*SubredditPost) GetAuthorFullname

func (x *SubredditPost) GetAuthorFullname() string

func (*SubredditPost) GetPosts

func (x *SubredditPost) GetPosts() int32

func (*SubredditPost) ProtoMessage

func (*SubredditPost) ProtoMessage()

func (*SubredditPost) ProtoReflect

func (x *SubredditPost) ProtoReflect() protoreflect.Message

func (*SubredditPost) Reset

func (x *SubredditPost) Reset()

func (*SubredditPost) String

func (x *SubredditPost) String() string

type UnimplementedRedditServiceServer

type UnimplementedRedditServiceServer struct {
}

UnimplementedRedditServiceServer should be embedded to have forward compatible implementations.

type UnsafeRedditServiceServer

type UnsafeRedditServiceServer interface {
	// contains filtered or unexported methods
}

UnsafeRedditServiceServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to RedditServiceServer will result in compilation errors.

Jump to

Keyboard shortcuts

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