http

package
v0.0.0-...-c508d84 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2017 License: MIT Imports: 10 Imported by: 0

README

Data subproject

This is meant to isolate all of the db transactions within the app, regardless of deployment type or decided archetecture

Post Decider Types:
  1. Random: Random
    • Needs only one decider model
  2. Popularity: Steps based off of reddit points
    • Needs one decider model per link
    • visits with referrals will be parsed and will try to attach the reddit post to the modulario post
    • two reddit posts should be able to visit the link with different results
  3. Altering
    • Based on points, do something different idk
The Decider

post -> []decider

if only one, it's probably random, but the decider will know

If more than one, iterate through and build a closure to evaluate the decision

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeCreatePostEndpoint

func MakeCreatePostEndpoint(svc HttpService) endpoint.Endpoint

func MakeHttpService

func MakeHttpService() *httpService

func MakeLoginEndpoint

func MakeLoginEndpoint(svc HttpService) endpoint.Endpoint

func MakeViewPostEndpoint

func MakeViewPostEndpoint(svc HttpService) endpoint.Endpoint

func MakeVisitPostEndpoint

func MakeVisitPostEndpoint(svc HttpService) endpoint.Endpoint

Types

type AttachedPost

type AttachedPost struct {
	gorm.Model
	ReferredPostID string
	PostID         uint `gorm:"index"`

	Metric uint

	Post Post
}

type Conditional

type Conditional struct {
	gorm.Model

	Threshold uint

	LinkID uint `gorm:"index"`
	PostID uint `gorm:"index"`
}

type Engine

type Engine struct {
	Dialect string
	Args    string
	LogMode bool
	// contains filtered or unexported fields
}

func (*Engine) AuthorizeUser

func (e *Engine) AuthorizeUser(username, password string) (user User, err error)

func (*Engine) BuildDecider

func (e *Engine) BuildDecider(post Post) func() Link

func (*Engine) BuildPopularityDecider

func (e *Engine) BuildPopularityDecider(post Post) func() Link

func (*Engine) BuildRandomDecider

func (e *Engine) BuildRandomDecider(post Post) func() Link

func (*Engine) CreatePost

func (e *Engine) CreatePost(user User, request proto.CreatePostRequest) (Post, error)

func (*Engine) CreateUser

func (e *Engine) CreateUser(username, password string) (User, error)

func (*Engine) DeletePost

func (e *Engine) DeletePost(key string) (err error)
func (e *Engine) GetLinks(post *Post) (err error)

func (*Engine) GetPost

func (e *Engine) GetPost(key string) (post Post, err error)
func (e *Engine) GetPostLinks(key string) (*Post, error)

func (*Engine) GetPostLinksdec

func (e *Engine) GetPostLinksdec(key string) (*Post, error)

func (*Engine) InitDB

func (e *Engine) InitDB()

func (*Engine) InitSchema

func (e *Engine) InitSchema()

func (*Engine) Login

func (e *Engine) Login(username, password string) (user User, err error)

func (*Engine) Register

func (e *Engine) Register(username, password string) (User, error)

func (*Engine) TotalPostVisits

func (e *Engine) TotalPostVisits(post *Post) (visits uint)

func (*Engine) VisitKey

func (e *Engine) VisitKey(key string) (Link, error)

func (*Engine) VisitPost

func (e *Engine) VisitPost(post *Post) (link Link, err error)
type Link struct {
	gorm.Model
	Url            string
	LastHttpStatus uint `gorm:"default:200"`
	Accesses       uint `gorm:"default:0"`
	PostID         uint `gorm:"index"`

	// this is for conditional stuffs
	Condition Conditional
}

type Post

type Post struct {
	gorm.Model
	Key    string `gorm:"index"`
	UserID uint   `gorm:"index"`
	Links  []Link // one to many

	DeciderType  string
	Conditionals []Conditional
	Decider      func() Link `gorm:"-" json:"-"`
}

type User

type User struct {
	gorm.Model
	Username string `gorm:"unique_index"`
	Password string
	Posts    []Post // one to many
}

Jump to

Keyboard shortcuts

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