service

package
v0.0.0-...-e4649f2 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package service provides implementation for a community-sentiment-analysis server. It provides an in-memory database implementation, http handlers, http routes, and a mechanism to start the server on a given port. It also implements a two-stage data processing pipeline, which allows for parallel processing, exploiting the cores that the hardware has to offer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Routes

func Routes(h *Handler) *chi.Mux

Routes specifies and returns the available http routes that are exposed as REST APIs. The allowed content type is JSON for all APIs. Authentication has been ignored for this demo service. A JWT based authentication can be implemented using the following packages:

  • github.com/dgrijalva/jwt-go
  • github.com/go-chi/jwtauth

Types

type App

type App struct {
	Cf config.Config
	// contains filtered or unexported fields
}

App contains the server configuration and http routes.

func GetApp

func GetApp() *App

GetApp instantiates an app with its configuration, handlers, and routes.

func (*App) StartServer

func (a *App) StartServer()

StartServer starts the http server for the supplied App instance.

type Handler

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

Handler exposes the base handler for the app.

func GetHandler

func GetHandler(db database.DataStore, c config.Config, vtc []chan pipeline.TweetText, ptc []chan pipeline.TweetText, vtr *pipeline.MemRR, ptr *pipeline.MemRR) *Handler

GetHandler returns an instance of handler.

func (*Handler) GetSentiments

func (h *Handler) GetSentiments(w http.ResponseWriter, r *http.Request)

GetSentiments is an http handler that returns all the sentiments, category-wise, from the db.

func (*Handler) SaveText

func (h *Handler) SaveText(w http.ResponseWriter, r *http.Request)

SaveText is an http handler that saves the incoming text in DB, update the corresponding sentiment, and returns success object.

type SaveTextReq

type SaveTextReq struct {
	TextString string
}

SaveTextReq represents a textString key of type string, incoming via http request body.

type SaveTextResp

type SaveTextResp struct {
	Saved bool
}

SaveTextResp is used for creating a response object for SaveText handler.

Jump to

Keyboard shortcuts

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