pairec

package module
v2.4.7 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: Apache-2.0 Imports: 55 Imported by: 0

README

pairec

A Go web framework for quickly building recommendation online services based on JSON configuration.

中文技术文档

Install

go get github.com/alibaba/pairec/v2

Quick Start

You can use pairecmd to quickly create project and start service .

From here, you can find a lot of useful configuration information.

PAIREC comes with a variety of built-in model functionalities, making it easy and fast to build recommendation services.

yuque_diagram

Introduction

Overall architecture

framework

When you use aliyun to deploy recommend service . The following diagram illustrates the overall deployment architecture.

image-20230727192436463

Documentation

Index

Constants

View Source
const (
	LOG_DEBUG = "DEBUG"
	LOG_INFO  = "INFO"
	LOG_ERROR = "ERROR"
	LOG_FATAL = "FATAL"

	LOG_OUTPUT_CONSOLE = "console"
)

Variables

This section is empty.

Functions

func AddStartHook

func AddStartHook(hf ...hookfunc)

func CallBackHookFunc added in v2.4.7

func CallBackHookFunc(context *context.RecommendContext, params ...any)

func ClearDir

func ClearDir(config recconf.LogConfig)

func Error

func Error(rw http.ResponseWriter, code int, msg string)

func Forward

func Forward(method, url, body string) *http.Response

func HandleFunc

func HandleFunc(pattern string, hf handleFunc)

func ListenConfig

func ListenConfig(configName string)

ListenConfig init a instace of ConfigLoader ConfigLoader will loop load paire config from server when the config version change

func Route

func Route(pattern string, c ControllerInterface)

func Run

func Run()

Types

type App

type App struct {
	Handlers *ControllerRegister
	Server   *http.Server
}
var (
	PairecApp *App
)

func NewApp

func NewApp() *App

func (*App) Run

func (app *App) Run()

func (*App) Use

func (app *App) Use(middleware ...MiddlewareFunc)

type ConfigLoader

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

func NewConfigLoader

func NewConfigLoader(configName string) *ConfigLoader

type ControllerInterface

type ControllerInterface interface {
	Process(http.ResponseWriter, *http.Request)
}

type ControllerRegister

type ControllerRegister struct {
	Middlewares []MiddlewareFunc
	// contains filtered or unexported fields
}

func NewControllerRegister

func NewControllerRegister() *ControllerRegister

func (*ControllerRegister) ApplyMiddlewares

func (c *ControllerRegister) ApplyMiddlewares()

func (*ControllerRegister) GetRoutePath added in v2.0.5

func (c *ControllerRegister) GetRoutePath() (paths []string)

func (*ControllerRegister) Register

func (c *ControllerRegister) Register(routeInfo *RouteInfo)

func (*ControllerRegister) ServeHTTP

func (c *ControllerRegister) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type MiddlewareController

type MiddlewareController struct {
	ControllerInterface
	Middlewares []MiddlewareFunc
}

func (MiddlewareController) Process

func (c MiddlewareController) Process(resp http.ResponseWriter, req *http.Request)

type MiddlewareFunc

type MiddlewareFunc func(handler func(http.ResponseWriter, *http.Request)) func(http.ResponseWriter, *http.Request)

type ResponseWriter

type ResponseWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

func NewResponseWriter

func NewResponseWriter(w http.ResponseWriter) *ResponseWriter

func (*ResponseWriter) Size

func (w *ResponseWriter) Size() int

func (*ResponseWriter) StatusCode

func (w *ResponseWriter) StatusCode() int

func (*ResponseWriter) Write

func (w *ResponseWriter) Write(b []byte) (n int, err error)

func (*ResponseWriter) WriteHeader

func (w *ResponseWriter) WriteHeader(statusCode int)

type RouteInfo

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

Jump to

Keyboard shortcuts

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