util

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: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BsonToRedditContent

func BsonToRedditContent(bsonBytes bson.Raw) (*pb.RedditContent, error)

takes in a bson.Raw object and returns a filled pb.RedditContent mainly used to convert mongo database compatible data to grpc compatible data

func GetEnv

func GetEnv(str string) string

get environment variable

func GetEnvDefault

func GetEnvDefault(str string, def string) string

equivelant to getEnv except doesn't cause an error and substitutes a default value (def)

func GetEnvInt

func GetEnvInt(str string) int

get an integer

func IsValidForDatabase

func IsValidForDatabase(rc *pb.RedditContent) error

perform this check on RedditContents before attempting to insert them into the database

returns nil if valid

func IsValidFullID

func IsValidFullID(ID string) bool

the listings in the database must store IDs in the form of t-_------, or regex ^t[1-6]_[a-z0-9]{6}$

func IsValidID

func IsValidID(ID string) bool

for IDs without the t3_-esque prefix

Types

type BsonStruct

type BsonStruct struct {
	ID      string `bson:"_id"`
	Listing bsonStructMetadata
	Entries []bsonStructEntry
}

middle-man object which bson pulled from database can be directly converted to (and vice versa), before converting to pb.RedditContent

func RedditContentToBson

func RedditContentToBson(r pb.RedditContent) BsonStruct

converts standard pb.RedditContent to object that can be parsed to database-compliant bson struct

Jump to

Keyboard shortcuts

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