consul: use acl cache struct in server

This commit is contained in:
Ryan Uber 2015-06-18 16:19:05 -07:00
parent e04a23801e
commit 6e9adae494
1 changed files with 5 additions and 20 deletions

View File

@ -16,7 +16,6 @@ import (
"github.com/hashicorp/consul/acl" "github.com/hashicorp/consul/acl"
"github.com/hashicorp/consul/tlsutil" "github.com/hashicorp/consul/tlsutil"
"github.com/hashicorp/golang-lru"
"github.com/hashicorp/raft" "github.com/hashicorp/raft"
"github.com/hashicorp/raft-boltdb" "github.com/hashicorp/raft-boltdb"
"github.com/hashicorp/serf/serf" "github.com/hashicorp/serf/serf"
@ -45,9 +44,6 @@ const (
// open to a server // open to a server
serverMaxStreams = 64 serverMaxStreams = 64
// Maximum number of cached ACL entries
aclCacheSize = 256
// raftLogCacheSize is the maximum number of logs to cache in-memory. // raftLogCacheSize is the maximum number of logs to cache in-memory.
// This is used to reduce disk I/O for the recently commited entries. // This is used to reduce disk I/O for the recently commited entries.
raftLogCacheSize = 512 raftLogCacheSize = 512
@ -63,11 +59,8 @@ type Server struct {
// aclAuthCache is the authoritative ACL cache // aclAuthCache is the authoritative ACL cache
aclAuthCache *acl.Cache aclAuthCache *acl.Cache
// aclCache is a non-authoritative ACL cache // aclCache is the non-authoritative ACL cache.
aclCache *lru.Cache aclCache *aclCache
// aclPolicyCache is a policy cache
aclPolicyCache *lru.Cache
// Consul configuration // Consul configuration
config *Config config *Config
@ -228,18 +221,10 @@ func NewServer(config *Config) (*Server, error) {
return nil, fmt.Errorf("Failed to create ACL cache: %v", err) return nil, fmt.Errorf("Failed to create ACL cache: %v", err)
} }
// Initialize the non-authoritative ACL cache // Set up the non-authoritative ACL cache
s.aclCache, err = lru.New(aclCacheSize) if s.aclCache, err = newAclCache(config, logger, s.RPC); err != nil {
if err != nil {
s.Shutdown() s.Shutdown()
return nil, fmt.Errorf("Failed to create ACL cache: %v", err) return nil, err
}
// Initialize the ACL policy cache
s.aclPolicyCache, err = lru.New(aclCacheSize)
if err != nil {
s.Shutdown()
return nil, fmt.Errorf("Failed to create ACL policy cache: %v", err)
} }
// Initialize the RPC layer // Initialize the RPC layer