mirror of
https://github.com/sot-tech/mochi.git
synced 2026-07-29 10:38:11 -07:00
s/trackerfuncs/trackerlogic
This commit is contained in:
@@ -6,10 +6,10 @@ import (
|
||||
"github.com/jzelinskie/trakr/bittorrent"
|
||||
)
|
||||
|
||||
// TrackerFuncs is the collection of callback functions provided by the Backend
|
||||
// to (1) generate a response from a parsed request, and (2) observe anything
|
||||
// TrackerLogic is the interface used by a frontend in order to: (1) generate a
|
||||
// response from a parsed request, and (2) asynchronously observe anything
|
||||
// after the response has been delivered to the client.
|
||||
type TrackerFuncs interface {
|
||||
type TrackerLogic interface {
|
||||
// HandleAnnounce generates a response for an Announce.
|
||||
HandleAnnounce(context.Context, *bittorrent.AnnounceRequest) (*bittorrent.AnnounceResponse, error)
|
||||
|
||||
|
||||
@@ -71,12 +71,12 @@ type Config struct {
|
||||
type Frontend struct {
|
||||
grace *graceful.Server
|
||||
|
||||
backend frontend.TrackerFuncs
|
||||
backend frontend.TrackerLogic
|
||||
Config
|
||||
}
|
||||
|
||||
// NewFrontend allocates a new instance of a Frontend.
|
||||
func NewFrontend(backend frontend.TrackerFuncs, cfg Config) *Frontend {
|
||||
func NewFrontend(backend frontend.TrackerLogic, cfg Config) *Frontend {
|
||||
return &Frontend{
|
||||
backend: backend,
|
||||
Config: cfg,
|
||||
@@ -138,7 +138,7 @@ func (t *Frontend) ListenAndServe() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// announceRoute parses and responds to an Announce by using t.TrackerFuncs.
|
||||
// announceRoute parses and responds to an Announce by using t.TrackerLogic.
|
||||
func (t *Frontend) announceRoute(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
||||
var err error
|
||||
start := time.Now()
|
||||
@@ -165,7 +165,7 @@ func (t *Frontend) announceRoute(w http.ResponseWriter, r *http.Request, _ httpr
|
||||
go t.backend.AfterAnnounce(context.TODO(), req, resp)
|
||||
}
|
||||
|
||||
// scrapeRoute parses and responds to a Scrape by using t.TrackerFuncs.
|
||||
// scrapeRoute parses and responds to a Scrape by using t.TrackerLogic.
|
||||
func (t *Frontend) scrapeRoute(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
|
||||
var err error
|
||||
start := time.Now()
|
||||
|
||||
@@ -74,12 +74,12 @@ type Frontend struct {
|
||||
closing chan struct{}
|
||||
wg sync.WaitGroup
|
||||
|
||||
backend frontend.TrackerFuncs
|
||||
backend frontend.TrackerLogic
|
||||
Config
|
||||
}
|
||||
|
||||
// NewFrontend allocates a new instance of a Frontend.
|
||||
func NewFrontend(backend frontend.TrackerFuncs, cfg Config) *Frontend {
|
||||
func NewFrontend(backend frontend.TrackerLogic, cfg Config) *Frontend {
|
||||
return &Frontend{
|
||||
closing: make(chan struct{}),
|
||||
backend: backend,
|
||||
|
||||
Reference in New Issue
Block a user