database

package
v0.0.0-...-0ec1176 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

holds an instance of the database connection

func Connect

func Connect() (*Connection, error)

call this function to establish a new connection with your mongodb db

func (Connection) CullListings

func (c Connection) CullListings(maxAge uint64) (uint32, error)

returns # of deleted listings

func (Connection) FetchListing

func (c Connection) FetchListing(ID string) (*pb.RedditContent, error)

FetchListing returns nil,nil in the case that no listing with that ID was found, and no other errors. Otherwise it will return listing, nil or nil, error depending on whether a different error occured

func (Connection) ManyListings

func (c Connection) ManyListings(limit uint32, skip uint32) ([]*pb.RedditContent, error)

func (Connection) RetrieveListings

func (c Connection) RetrieveListings(maxAge uint64, out chan<- *pb.RedditContent, outErr chan<- error)

this function outputs it's retrieved listings via the out channel. This is because this function will be used to in a grpc endpoint that streams it's result, so it's generally more memory and speed efficient for this function to stream data out as well.

func (Connection) SaveListings

func (c Connection) SaveListings(numListings uint32, in <-chan *pb.RedditContent, errOut chan<- error, errOutInternal chan<- error)

stream data into in parameter.

use errOut for errors visible to the API consumer use errOutInteral for internal server errors

only write to one of these channels before exiting. If there are no errors, write nil to either

func (Connection) UpdateListings

func (c Connection) UpdateListings(numListings uint32, in <-chan *pb.RedditContent, errOut chan<- error, errOutInternal chan<- error)

This function, it's inputs especially, are practically the same as SaveListings

Jump to

Keyboard shortcuts

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