package debug

import (
	"strings"
	"time"

	"veyron.io/veyron/veyron2/ipc"
	"veyron.io/veyron/veyron2/security"
	"veyron.io/veyron/veyron2/vtrace"

	logreaderimpl "veyron.io/veyron/veyron/services/mgmt/logreader/impl"
	pprofimpl "veyron.io/veyron/veyron/services/mgmt/pprof/impl"
	statsimpl "veyron.io/veyron/veyron/services/mgmt/stats/impl"
	vtraceimpl "veyron.io/veyron/veyron/services/mgmt/vtrace/impl"
)

// dispatcher holds the state of the debug dispatcher.
type dispatcher struct {
	logsDir string // The root of the logs directory.
	auth    security.Authorizer
	store   vtrace.Store
}

var _ ipc.Dispatcher = (*dispatcher)(nil)

func NewDispatcher(logsDir string, authorizer security.Authorizer, store vtrace.Store) *dispatcher {
	return &dispatcher{logsDir, authorizer, store}
}

// The first part of the names of the objects served by this dispatcher.
var rootName = "__debug"

func (d *dispatcher) Lookup(suffix string) (interface{}, security.Authorizer, error) {
	if suffix == "" {
		return ipc.ChildrenGlobberInvoker(rootName), d.auth, nil
	}
	if !strings.HasPrefix(suffix, rootName) {
		return nil, nil, nil
	}
	suffix = strings.TrimPrefix(suffix, rootName)
	suffix = strings.TrimLeft(suffix, "/")

	if suffix == "" {
		return ipc.ChildrenGlobberInvoker("logs", "pprof", "stats", "vtrace"), d.auth, nil
	}
	parts := strings.SplitN(suffix, "/", 2)
	if len(parts) == 2 {
		suffix = parts[1]
	} else {
		suffix = ""
	}
	switch parts[0] {
	case "logs":
		return logreaderimpl.NewLogFileService(d.logsDir, suffix), d.auth, nil
	case "pprof":
		return pprofimpl.NewPProfService(), d.auth, nil
	case "stats":
		return statsimpl.NewStatsService(suffix, 10*time.Second), d.auth, nil
	case "vtrace":
		return vtraceimpl.NewVtraceService(d.store), d.auth, nil
	}
	return nil, d.auth, nil
}
