/
dispatcher.go
50 lines (40 loc) · 1.01 KB
/
dispatcher.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2016 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package internal
import (
"path"
"v.io/v23/context"
"v.io/v23/rpc"
"v.io/v23/security"
"v.io/v23/security/access"
v23mt "v.io/v23/services/mounttable"
"v.io/x/ref/lib/timekeeper"
)
type Config struct {
GlobalAcl access.AccessList
MaxNodesPerUser int64
MaxServersPerUser int64
}
var clock = timekeeper.RealTime()
// For testing only.
func SetClock(c timekeeper.TimeKeeper) {
clock = c
}
func NewDispatcher(bt *BigTable, config *Config) rpc.Dispatcher {
return &dispatcher{bt, config}
}
type dispatcher struct {
bt *BigTable
config *Config
}
func (d *dispatcher) Lookup(ctx *context.T, suffix string) (interface{}, security.Authorizer, error) {
if suffix != "" {
suffix = path.Clean(suffix)
}
return v23mt.MountTableServer(&mounttable{
suffix: suffix,
config: d.config,
bt: d.bt,
}), security.AllowEveryone(), nil
}