From 1acff3533ed3f00d15da8c7e9735b6c2f7c9bfc8 Mon Sep 17 00:00:00 2001 From: Frank Schroeder Date: Thu, 6 Jul 2017 12:34:00 +0200 Subject: [PATCH 1/3] agent: move agent/consul/structs to agent/structs --- agent/acl.go | 2 +- agent/acl_endpoint.go | 2 +- agent/acl_endpoint_test.go | 2 +- agent/acl_test.go | 2 +- agent/agent.go | 2 +- agent/agent_endpoint.go | 2 +- agent/agent_endpoint_test.go | 2 +- agent/agent_test.go | 2 +- agent/catalog_endpoint.go | 2 +- agent/catalog_endpoint_test.go | 2 +- agent/check.go | 2 +- agent/config.go | 2 +- agent/config_test.go | 2 +- agent/consul/acl.go | 2 +- agent/consul/acl_endpoint.go | 2 +- agent/consul/acl_endpoint_test.go | 2 +- agent/consul/acl_replication.go | 2 +- agent/consul/acl_replication_test.go | 2 +- agent/consul/acl_test.go | 2 +- agent/consul/autopilot.go | 2 +- agent/consul/catalog_endpoint.go | 2 +- agent/consul/catalog_endpoint_test.go | 2 +- agent/consul/client.go | 2 +- agent/consul/client_test.go | 2 +- agent/consul/config.go | 2 +- agent/consul/coordinate_endpoint.go | 2 +- agent/consul/coordinate_endpoint_test.go | 2 +- agent/consul/filter.go | 2 +- agent/consul/filter_test.go | 2 +- agent/consul/fsm.go | 2 +- agent/consul/fsm_test.go | 2 +- agent/consul/health_endpoint.go | 2 +- agent/consul/health_endpoint_test.go | 2 +- agent/consul/internal_endpoint.go | 2 +- agent/consul/internal_endpoint_test.go | 2 +- agent/consul/issue_test.go | 2 +- agent/consul/kvs_endpoint.go | 2 +- agent/consul/kvs_endpoint_test.go | 2 +- agent/consul/leader.go | 2 +- agent/consul/leader_test.go | 2 +- agent/consul/operator_autopilot_endpoint.go | 2 +- agent/consul/operator_autopilot_endpoint_test.go | 2 +- agent/consul/operator_raft_endpoint.go | 2 +- agent/consul/operator_raft_endpoint_test.go | 2 +- agent/consul/prepared_query/template.go | 2 +- agent/consul/prepared_query/template_test.go | 2 +- agent/consul/prepared_query/walk_test.go | 2 +- agent/consul/prepared_query_endpoint.go | 2 +- agent/consul/prepared_query_endpoint_test.go | 2 +- agent/consul/rpc.go | 2 +- agent/consul/rpc_test.go | 2 +- agent/consul/rtt.go | 2 +- agent/consul/rtt_test.go | 2 +- agent/consul/server.go | 2 +- agent/consul/servers/router.go | 2 +- agent/consul/servers/router_test.go | 2 +- agent/consul/session_endpoint.go | 2 +- agent/consul/session_endpoint_test.go | 2 +- agent/consul/session_ttl.go | 2 +- agent/consul/session_ttl_test.go | 2 +- agent/consul/snapshot_endpoint.go | 2 +- agent/consul/snapshot_endpoint_test.go | 2 +- agent/consul/state/acl.go | 2 +- agent/consul/state/acl_test.go | 2 +- agent/consul/state/autopilot.go | 2 +- agent/consul/state/autopilot_test.go | 2 +- agent/consul/state/catalog.go | 2 +- agent/consul/state/catalog_test.go | 2 +- agent/consul/state/coordinate.go | 2 +- agent/consul/state/coordinate_test.go | 2 +- agent/consul/state/kvs.go | 2 +- agent/consul/state/kvs_test.go | 2 +- agent/consul/state/prepared_query.go | 2 +- agent/consul/state/prepared_query_index_test.go | 2 +- agent/consul/state/prepared_query_test.go | 2 +- agent/consul/state/session.go | 2 +- agent/consul/state/session_test.go | 2 +- agent/consul/state/state_store_test.go | 2 +- agent/consul/state/txn.go | 2 +- agent/consul/state/txn_test.go | 2 +- agent/consul/stats_fetcher.go | 2 +- agent/consul/status_endpoint.go | 2 +- agent/consul/txn_endpoint.go | 2 +- agent/consul/txn_endpoint_test.go | 2 +- agent/coordinate_endpoint.go | 2 +- agent/coordinate_endpoint_test.go | 2 +- agent/dns.go | 2 +- agent/dns_test.go | 2 +- agent/event_endpoint.go | 2 +- agent/event_endpoint_test.go | 2 +- agent/health_endpoint.go | 2 +- agent/health_endpoint_test.go | 2 +- agent/http.go | 2 +- agent/http_test.go | 2 +- agent/keyring.go | 2 +- agent/kvs_endpoint.go | 2 +- agent/kvs_endpoint_test.go | 2 +- agent/local.go | 2 +- agent/local_test.go | 2 +- agent/operator_endpoint.go | 2 +- agent/operator_endpoint_test.go | 2 +- agent/prepared_query_endpoint.go | 2 +- agent/prepared_query_endpoint_test.go | 2 +- agent/remote_exec.go | 2 +- agent/remote_exec_test.go | 2 +- agent/session_endpoint.go | 2 +- agent/session_endpoint_test.go | 2 +- agent/snapshot_endpoint.go | 2 +- agent/{consul => }/structs/acl.go | 0 agent/{consul => }/structs/acl_test.go | 0 agent/{consul => }/structs/catalog.go | 0 agent/{consul => }/structs/check_definition.go | 0 agent/{consul => }/structs/check_definition_test.go | 0 agent/{consul => }/structs/check_type.go | 0 agent/{consul => }/structs/operator.go | 0 agent/{consul => }/structs/operator_test.go | 0 agent/{consul => }/structs/prepared_query.go | 0 agent/{consul => }/structs/prepared_query_test.go | 0 agent/{consul => }/structs/service_definition.go | 0 agent/{consul => }/structs/service_definition_test.go | 0 agent/{consul => }/structs/snapshot.go | 0 agent/{consul => }/structs/structs.go | 0 agent/{consul => }/structs/structs_test.go | 0 agent/{consul => }/structs/txn.go | 0 agent/testagent.go | 2 +- agent/translate_addr.go | 2 +- agent/txn_endpoint.go | 2 +- agent/txn_endpoint_test.go | 2 +- agent/ui_endpoint.go | 2 +- agent/ui_endpoint_test.go | 2 +- agent/user_event.go | 2 +- agent/user_event_test.go | 2 +- command/agent.go | 2 +- command/maint_test.go | 2 +- command/operator_autopilot_set_test.go | 2 +- command/rtt_test.go | 2 +- testrpc/wait.go | 2 +- 137 files changed, 121 insertions(+), 121 deletions(-) rename agent/{consul => }/structs/acl.go (100%) rename agent/{consul => }/structs/acl_test.go (100%) rename agent/{consul => }/structs/catalog.go (100%) rename agent/{consul => }/structs/check_definition.go (100%) rename agent/{consul => }/structs/check_definition_test.go (100%) rename agent/{consul => }/structs/check_type.go (100%) rename agent/{consul => }/structs/operator.go (100%) rename agent/{consul => }/structs/operator_test.go (100%) rename agent/{consul => }/structs/prepared_query.go (100%) rename agent/{consul => }/structs/prepared_query_test.go (100%) rename agent/{consul => }/structs/service_definition.go (100%) rename agent/{consul => }/structs/service_definition_test.go (100%) rename agent/{consul => }/structs/snapshot.go (100%) rename agent/{consul => }/structs/structs.go (100%) rename agent/{consul => }/structs/structs_test.go (100%) rename agent/{consul => }/structs/txn.go (100%) diff --git a/agent/acl.go b/agent/acl.go index f77642bae5..8c6a4c6707 100644 --- a/agent/acl.go +++ b/agent/acl.go @@ -9,7 +9,7 @@ import ( "github.com/armon/go-metrics" "github.com/hashicorp/consul/acl" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/types" "github.com/hashicorp/golang-lru" "github.com/hashicorp/serf/serf" diff --git a/agent/acl_endpoint.go b/agent/acl_endpoint.go index 6138c899d7..b7df333c3f 100644 --- a/agent/acl_endpoint.go +++ b/agent/acl_endpoint.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" ) // aclCreateResponse is used to wrap the ACL ID diff --git a/agent/acl_endpoint_test.go b/agent/acl_endpoint_test.go index 0eac877978..2db4550303 100644 --- a/agent/acl_endpoint_test.go +++ b/agent/acl_endpoint_test.go @@ -7,7 +7,7 @@ import ( "net/http/httptest" "testing" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" ) func makeTestACL(t *testing.T, srv *HTTPServer) string { diff --git a/agent/acl_test.go b/agent/acl_test.go index 44980abcf4..5de913a889 100644 --- a/agent/acl_test.go +++ b/agent/acl_test.go @@ -8,7 +8,7 @@ import ( "time" rawacl "github.com/hashicorp/consul/acl" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/testutil" "github.com/hashicorp/consul/types" "github.com/hashicorp/serf/serf" diff --git a/agent/agent.go b/agent/agent.go index e9095d8ad4..ecb7798f0f 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -20,7 +20,7 @@ import ( "github.com/armon/go-metrics" "github.com/hashicorp/consul/agent/consul" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/agent/systemd" "github.com/hashicorp/consul/agent/token" "github.com/hashicorp/consul/api" diff --git a/agent/agent_endpoint.go b/agent/agent_endpoint.go index 1ce49faec0..6dac291a3e 100644 --- a/agent/agent_endpoint.go +++ b/agent/agent_endpoint.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/ipaddr" "github.com/hashicorp/consul/logger" diff --git a/agent/agent_endpoint_test.go b/agent/agent_endpoint_test.go index 0b2dd2f0eb..c28e9c8941 100644 --- a/agent/agent_endpoint_test.go +++ b/agent/agent_endpoint_test.go @@ -13,7 +13,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/logger" "github.com/hashicorp/consul/testutil/retry" diff --git a/agent/agent_test.go b/agent/agent_test.go index e5cf02edcc..3ffbacc22f 100644 --- a/agent/agent_test.go +++ b/agent/agent_test.go @@ -15,7 +15,7 @@ import ( "time" "github.com/hashicorp/consul/agent/consul" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/testutil" "github.com/hashicorp/consul/types" diff --git a/agent/catalog_endpoint.go b/agent/catalog_endpoint.go index 34da83fa74..d71658653b 100644 --- a/agent/catalog_endpoint.go +++ b/agent/catalog_endpoint.go @@ -5,7 +5,7 @@ import ( "net/http" "strings" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" ) func (s *HTTPServer) CatalogRegister(resp http.ResponseWriter, req *http.Request) (interface{}, error) { diff --git a/agent/catalog_endpoint_test.go b/agent/catalog_endpoint_test.go index aa08fcf267..b4ebd21446 100644 --- a/agent/catalog_endpoint_test.go +++ b/agent/catalog_endpoint_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/serf/coordinate" ) diff --git a/agent/check.go b/agent/check.go index 3060405fa5..d99dcc33e8 100644 --- a/agent/check.go +++ b/agent/check.go @@ -15,7 +15,7 @@ import ( "time" "github.com/armon/circbuf" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/types" diff --git a/agent/config.go b/agent/config.go index ee57b47796..849d36127c 100644 --- a/agent/config.go +++ b/agent/config.go @@ -16,7 +16,7 @@ import ( "time" "github.com/hashicorp/consul/agent/consul" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/ipaddr" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/tlsutil" diff --git a/agent/config_test.go b/agent/config_test.go index 5b83c677d6..7f0df3f06d 100644 --- a/agent/config_test.go +++ b/agent/config_test.go @@ -14,7 +14,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/testutil" "github.com/pascaldekloe/goe/verify" ) diff --git a/agent/consul/acl.go b/agent/consul/acl.go index ead3a25be7..47454f98ec 100644 --- a/agent/consul/acl.go +++ b/agent/consul/acl.go @@ -10,7 +10,7 @@ import ( "github.com/armon/go-metrics" "github.com/hashicorp/consul/acl" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/golang-lru" ) diff --git a/agent/consul/acl_endpoint.go b/agent/consul/acl_endpoint.go index eb63557309..202b5d2c7c 100644 --- a/agent/consul/acl_endpoint.go +++ b/agent/consul/acl_endpoint.go @@ -7,7 +7,7 @@ import ( "github.com/armon/go-metrics" "github.com/hashicorp/consul/acl" "github.com/hashicorp/consul/agent/consul/state" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/go-memdb" "github.com/hashicorp/go-uuid" ) diff --git a/agent/consul/acl_endpoint_test.go b/agent/consul/acl_endpoint_test.go index 246d66db8b..9c49ece2be 100644 --- a/agent/consul/acl_endpoint_test.go +++ b/agent/consul/acl_endpoint_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil/retry" diff --git a/agent/consul/acl_replication.go b/agent/consul/acl_replication.go index f0b40d4d45..41cbe5dca5 100644 --- a/agent/consul/acl_replication.go +++ b/agent/consul/acl_replication.go @@ -6,7 +6,7 @@ import ( "time" "github.com/armon/go-metrics" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/lib" ) diff --git a/agent/consul/acl_replication_test.go b/agent/consul/acl_replication_test.go index 6040c062df..ea62fa0a06 100644 --- a/agent/consul/acl_replication_test.go +++ b/agent/consul/acl_replication_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil/retry" ) diff --git a/agent/consul/acl_test.go b/agent/consul/acl_test.go index 2f7746b3a3..00a2c00922 100644 --- a/agent/consul/acl_test.go +++ b/agent/consul/acl_test.go @@ -8,7 +8,7 @@ import ( "time" "github.com/hashicorp/consul/acl" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil/retry" ) diff --git a/agent/consul/autopilot.go b/agent/consul/autopilot.go index 5b81bb0ce4..fe02256da3 100644 --- a/agent/consul/autopilot.go +++ b/agent/consul/autopilot.go @@ -9,7 +9,7 @@ import ( "github.com/armon/go-metrics" "github.com/hashicorp/consul/agent/consul/agent" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/go-version" "github.com/hashicorp/raft" "github.com/hashicorp/serf/serf" diff --git a/agent/consul/catalog_endpoint.go b/agent/consul/catalog_endpoint.go index 06ad854948..e68ac49fab 100644 --- a/agent/consul/catalog_endpoint.go +++ b/agent/consul/catalog_endpoint.go @@ -6,7 +6,7 @@ import ( "github.com/armon/go-metrics" "github.com/hashicorp/consul/agent/consul/state" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/ipaddr" "github.com/hashicorp/consul/types" "github.com/hashicorp/go-memdb" diff --git a/agent/consul/catalog_endpoint_test.go b/agent/consul/catalog_endpoint_test.go index 77ade9de43..4c2529daba 100644 --- a/agent/consul/catalog_endpoint_test.go +++ b/agent/consul/catalog_endpoint_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/testrpc" diff --git a/agent/consul/client.go b/agent/consul/client.go index 87476e7cfd..8e23e4b884 100644 --- a/agent/consul/client.go +++ b/agent/consul/client.go @@ -13,8 +13,8 @@ import ( "github.com/hashicorp/consul/agent/consul/agent" "github.com/hashicorp/consul/agent/consul/servers" - "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/agent/pool" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/serf/coordinate" "github.com/hashicorp/serf/serf" diff --git a/agent/consul/client_test.go b/agent/consul/client_test.go index b908569c12..e5a79d1aa6 100644 --- a/agent/consul/client_test.go +++ b/agent/consul/client_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil" "github.com/hashicorp/consul/testutil/retry" diff --git a/agent/consul/config.go b/agent/consul/config.go index bb6a431a17..771f72df59 100644 --- a/agent/consul/config.go +++ b/agent/consul/config.go @@ -7,7 +7,7 @@ import ( "os" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/tlsutil" "github.com/hashicorp/consul/types" "github.com/hashicorp/memberlist" diff --git a/agent/consul/coordinate_endpoint.go b/agent/consul/coordinate_endpoint.go index 696a6be37c..4e0790d302 100644 --- a/agent/consul/coordinate_endpoint.go +++ b/agent/consul/coordinate_endpoint.go @@ -7,7 +7,7 @@ import ( "time" "github.com/hashicorp/consul/agent/consul/state" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/go-memdb" "github.com/hashicorp/serf/coordinate" ) diff --git a/agent/consul/coordinate_endpoint_test.go b/agent/consul/coordinate_endpoint_test.go index 380446a91a..3f59b8ac22 100644 --- a/agent/consul/coordinate_endpoint_test.go +++ b/agent/consul/coordinate_endpoint_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/net-rpc-msgpackrpc" diff --git a/agent/consul/filter.go b/agent/consul/filter.go index 88be1b99c3..040aa8ef60 100644 --- a/agent/consul/filter.go +++ b/agent/consul/filter.go @@ -2,7 +2,7 @@ package consul import ( "github.com/hashicorp/consul/acl" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" ) type dirEntFilter struct { diff --git a/agent/consul/filter_test.go b/agent/consul/filter_test.go index eb5218d53a..ac8fcff9f1 100644 --- a/agent/consul/filter_test.go +++ b/agent/consul/filter_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/hashicorp/consul/acl" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" ) func TestFilter_DirEnt(t *testing.T) { diff --git a/agent/consul/fsm.go b/agent/consul/fsm.go index 9481ea35a1..202fcdc2af 100644 --- a/agent/consul/fsm.go +++ b/agent/consul/fsm.go @@ -9,7 +9,7 @@ import ( "github.com/armon/go-metrics" "github.com/hashicorp/consul/agent/consul/state" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/go-msgpack/codec" "github.com/hashicorp/raft" diff --git a/agent/consul/fsm_test.go b/agent/consul/fsm_test.go index ddd5cebf59..0fea8fc2bc 100644 --- a/agent/consul/fsm_test.go +++ b/agent/consul/fsm_test.go @@ -9,7 +9,7 @@ import ( "time" "github.com/hashicorp/consul/agent/consul/state" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/types" diff --git a/agent/consul/health_endpoint.go b/agent/consul/health_endpoint.go index b930d3032e..2967df094e 100644 --- a/agent/consul/health_endpoint.go +++ b/agent/consul/health_endpoint.go @@ -5,7 +5,7 @@ import ( "github.com/armon/go-metrics" "github.com/hashicorp/consul/agent/consul/state" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/go-memdb" ) diff --git a/agent/consul/health_endpoint_test.go b/agent/consul/health_endpoint_test.go index 90bb491633..3f44e78c9d 100644 --- a/agent/consul/health_endpoint_test.go +++ b/agent/consul/health_endpoint_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/testrpc" diff --git a/agent/consul/internal_endpoint.go b/agent/consul/internal_endpoint.go index 546d66975c..5d5c0b6826 100644 --- a/agent/consul/internal_endpoint.go +++ b/agent/consul/internal_endpoint.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/hashicorp/consul/agent/consul/state" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/go-memdb" "github.com/hashicorp/serf/serf" ) diff --git a/agent/consul/internal_endpoint_test.go b/agent/consul/internal_endpoint_test.go index 97c41f94f8..b1d7721187 100644 --- a/agent/consul/internal_endpoint_test.go +++ b/agent/consul/internal_endpoint_test.go @@ -5,7 +5,7 @@ import ( "os" "testing" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/testrpc" diff --git a/agent/consul/issue_test.go b/agent/consul/issue_test.go index 3f0435fcc0..9f7581ed0b 100644 --- a/agent/consul/issue_test.go +++ b/agent/consul/issue_test.go @@ -5,7 +5,7 @@ import ( "reflect" "testing" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" ) diff --git a/agent/consul/kvs_endpoint.go b/agent/consul/kvs_endpoint.go index e880a8a481..ab1d04844c 100644 --- a/agent/consul/kvs_endpoint.go +++ b/agent/consul/kvs_endpoint.go @@ -7,7 +7,7 @@ import ( "github.com/armon/go-metrics" "github.com/hashicorp/consul/acl" "github.com/hashicorp/consul/agent/consul/state" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/go-memdb" ) diff --git a/agent/consul/kvs_endpoint_test.go b/agent/consul/kvs_endpoint_test.go index b03816b6e8..de668e3168 100644 --- a/agent/consul/kvs_endpoint_test.go +++ b/agent/consul/kvs_endpoint_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/net-rpc-msgpackrpc" diff --git a/agent/consul/leader.go b/agent/consul/leader.go index 07a03d3591..1d3c60c931 100644 --- a/agent/consul/leader.go +++ b/agent/consul/leader.go @@ -10,7 +10,7 @@ import ( "github.com/armon/go-metrics" "github.com/hashicorp/consul/agent/consul/agent" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/types" "github.com/hashicorp/go-version" diff --git a/agent/consul/leader_test.go b/agent/consul/leader_test.go index 7189725247..b879bc75a8 100644 --- a/agent/consul/leader_test.go +++ b/agent/consul/leader_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil/retry" diff --git a/agent/consul/operator_autopilot_endpoint.go b/agent/consul/operator_autopilot_endpoint.go index 141d321790..07b102a77e 100644 --- a/agent/consul/operator_autopilot_endpoint.go +++ b/agent/consul/operator_autopilot_endpoint.go @@ -3,7 +3,7 @@ package consul import ( "fmt" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" ) // AutopilotGetConfiguration is used to retrieve the current Autopilot configuration. diff --git a/agent/consul/operator_autopilot_endpoint_test.go b/agent/consul/operator_autopilot_endpoint_test.go index f2c624630a..2e02e2c568 100644 --- a/agent/consul/operator_autopilot_endpoint_test.go +++ b/agent/consul/operator_autopilot_endpoint_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/net-rpc-msgpackrpc" diff --git a/agent/consul/operator_raft_endpoint.go b/agent/consul/operator_raft_endpoint.go index d4feeeb1d1..84e7369607 100644 --- a/agent/consul/operator_raft_endpoint.go +++ b/agent/consul/operator_raft_endpoint.go @@ -5,7 +5,7 @@ import ( "net" "github.com/hashicorp/consul/agent/consul/agent" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/raft" "github.com/hashicorp/serf/serf" ) diff --git a/agent/consul/operator_raft_endpoint_test.go b/agent/consul/operator_raft_endpoint_test.go index fef95dd384..1735548442 100644 --- a/agent/consul/operator_raft_endpoint_test.go +++ b/agent/consul/operator_raft_endpoint_test.go @@ -7,7 +7,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/net-rpc-msgpackrpc" "github.com/hashicorp/raft" diff --git a/agent/consul/prepared_query/template.go b/agent/consul/prepared_query/template.go index 5b7b48421f..eab1e49f74 100644 --- a/agent/consul/prepared_query/template.go +++ b/agent/consul/prepared_query/template.go @@ -6,7 +6,7 @@ import ( "regexp" "strings" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/hil" "github.com/hashicorp/hil/ast" "github.com/mitchellh/copystructure" diff --git a/agent/consul/prepared_query/template_test.go b/agent/consul/prepared_query/template_test.go index 5fe7fb7a75..ef445f9c5e 100644 --- a/agent/consul/prepared_query/template_test.go +++ b/agent/consul/prepared_query/template_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/mitchellh/copystructure" ) diff --git a/agent/consul/prepared_query/walk_test.go b/agent/consul/prepared_query/walk_test.go index 9d9d9533cb..b0eb534dd8 100644 --- a/agent/consul/prepared_query/walk_test.go +++ b/agent/consul/prepared_query/walk_test.go @@ -7,7 +7,7 @@ import ( "sort" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" ) func TestWalk_ServiceQuery(t *testing.T) { diff --git a/agent/consul/prepared_query_endpoint.go b/agent/consul/prepared_query_endpoint.go index 3b78702a7e..9dbf0c86e1 100644 --- a/agent/consul/prepared_query_endpoint.go +++ b/agent/consul/prepared_query_endpoint.go @@ -9,7 +9,7 @@ import ( "github.com/armon/go-metrics" "github.com/hashicorp/consul/agent/consul/state" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/go-memdb" "github.com/hashicorp/go-uuid" ) diff --git a/agent/consul/prepared_query_endpoint_test.go b/agent/consul/prepared_query_endpoint_test.go index 16e332d6dd..b07e5b206b 100644 --- a/agent/consul/prepared_query_endpoint_test.go +++ b/agent/consul/prepared_query_endpoint_test.go @@ -12,7 +12,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil/retry" diff --git a/agent/consul/rpc.go b/agent/consul/rpc.go index 3fd544b41a..3777e08c8a 100644 --- a/agent/consul/rpc.go +++ b/agent/consul/rpc.go @@ -11,8 +11,8 @@ import ( "github.com/armon/go-metrics" "github.com/hashicorp/consul/agent/consul/agent" "github.com/hashicorp/consul/agent/consul/state" - "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/agent/pool" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/go-memdb" "github.com/hashicorp/memberlist" diff --git a/agent/consul/rpc_test.go b/agent/consul/rpc_test.go index 8c0779e067..2551878313 100644 --- a/agent/consul/rpc_test.go +++ b/agent/consul/rpc_test.go @@ -7,7 +7,7 @@ import ( "time" "github.com/hashicorp/consul/agent/consul/state" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/go-memdb" diff --git a/agent/consul/rtt.go b/agent/consul/rtt.go index 392f13d4fa..50802d5689 100644 --- a/agent/consul/rtt.go +++ b/agent/consul/rtt.go @@ -4,7 +4,7 @@ import ( "fmt" "sort" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/serf/coordinate" ) diff --git a/agent/consul/rtt_test.go b/agent/consul/rtt_test.go index 78e2efee72..7a56971f2e 100644 --- a/agent/consul/rtt_test.go +++ b/agent/consul/rtt_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/net-rpc-msgpackrpc" diff --git a/agent/consul/server.go b/agent/consul/server.go index 694426c4d2..5c89e9e051 100644 --- a/agent/consul/server.go +++ b/agent/consul/server.go @@ -21,8 +21,8 @@ import ( "github.com/hashicorp/consul/agent/consul/agent" "github.com/hashicorp/consul/agent/consul/servers" "github.com/hashicorp/consul/agent/consul/state" - "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/agent/pool" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/agent/token" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/tlsutil" diff --git a/agent/consul/servers/router.go b/agent/consul/servers/router.go index f75f354285..b295cca83a 100644 --- a/agent/consul/servers/router.go +++ b/agent/consul/servers/router.go @@ -7,7 +7,7 @@ import ( "sync" "github.com/hashicorp/consul/agent/consul/agent" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/types" "github.com/hashicorp/serf/coordinate" diff --git a/agent/consul/servers/router_test.go b/agent/consul/servers/router_test.go index 230031f8aa..c6f430079c 100644 --- a/agent/consul/servers/router_test.go +++ b/agent/consul/servers/router_test.go @@ -11,7 +11,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/types" "github.com/hashicorp/serf/coordinate" diff --git a/agent/consul/session_endpoint.go b/agent/consul/session_endpoint.go index d8379ff947..7d145d03d7 100644 --- a/agent/consul/session_endpoint.go +++ b/agent/consul/session_endpoint.go @@ -6,7 +6,7 @@ import ( "github.com/armon/go-metrics" "github.com/hashicorp/consul/agent/consul/state" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/go-memdb" "github.com/hashicorp/go-uuid" ) diff --git a/agent/consul/session_endpoint_test.go b/agent/consul/session_endpoint_test.go index c4a0c71644..20c7e4611d 100644 --- a/agent/consul/session_endpoint_test.go +++ b/agent/consul/session_endpoint_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/net-rpc-msgpackrpc" diff --git a/agent/consul/session_ttl.go b/agent/consul/session_ttl.go index 35441d9543..53a1840edf 100644 --- a/agent/consul/session_ttl.go +++ b/agent/consul/session_ttl.go @@ -5,7 +5,7 @@ import ( "time" "github.com/armon/go-metrics" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" ) const ( diff --git a/agent/consul/session_ttl_test.go b/agent/consul/session_ttl_test.go index 2922ee578b..2bc7dc7aae 100644 --- a/agent/consul/session_ttl_test.go +++ b/agent/consul/session_ttl_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/net-rpc-msgpackrpc" diff --git a/agent/consul/snapshot_endpoint.go b/agent/consul/snapshot_endpoint.go index 227a872fdc..7b798cabcc 100644 --- a/agent/consul/snapshot_endpoint.go +++ b/agent/consul/snapshot_endpoint.go @@ -16,8 +16,8 @@ import ( "net" "time" - "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/agent/pool" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/snapshot" "github.com/hashicorp/go-msgpack/codec" ) diff --git a/agent/consul/snapshot_endpoint_test.go b/agent/consul/snapshot_endpoint_test.go index cb5ca82e9d..7bfe8503ad 100644 --- a/agent/consul/snapshot_endpoint_test.go +++ b/agent/consul/snapshot_endpoint_test.go @@ -6,7 +6,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil/retry" diff --git a/agent/consul/state/acl.go b/agent/consul/state/acl.go index da1d9f8eaf..8911b604d5 100644 --- a/agent/consul/state/acl.go +++ b/agent/consul/state/acl.go @@ -3,7 +3,7 @@ package state import ( "fmt" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/go-memdb" ) diff --git a/agent/consul/state/acl_test.go b/agent/consul/state/acl_test.go index 6a2a42fdcd..9a78fe47a1 100644 --- a/agent/consul/state/acl_test.go +++ b/agent/consul/state/acl_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/go-memdb" "github.com/pascaldekloe/goe/verify" ) diff --git a/agent/consul/state/autopilot.go b/agent/consul/state/autopilot.go index 9469a20fe4..89f81a9848 100644 --- a/agent/consul/state/autopilot.go +++ b/agent/consul/state/autopilot.go @@ -3,7 +3,7 @@ package state import ( "fmt" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/go-memdb" ) diff --git a/agent/consul/state/autopilot_test.go b/agent/consul/state/autopilot_test.go index 14a772aef2..bfe1be8a00 100644 --- a/agent/consul/state/autopilot_test.go +++ b/agent/consul/state/autopilot_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/pascaldekloe/goe/verify" ) diff --git a/agent/consul/state/catalog.go b/agent/consul/state/catalog.go index 173fa85c01..e9249e26d9 100644 --- a/agent/consul/state/catalog.go +++ b/agent/consul/state/catalog.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/types" "github.com/hashicorp/go-memdb" diff --git a/agent/consul/state/catalog_test.go b/agent/consul/state/catalog_test.go index b5ca5df460..e948b092c4 100644 --- a/agent/consul/state/catalog_test.go +++ b/agent/consul/state/catalog_test.go @@ -7,7 +7,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/types" diff --git a/agent/consul/state/coordinate.go b/agent/consul/state/coordinate.go index 38696f3154..9d05e05d1c 100644 --- a/agent/consul/state/coordinate.go +++ b/agent/consul/state/coordinate.go @@ -3,7 +3,7 @@ package state import ( "fmt" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/go-memdb" "github.com/hashicorp/serf/coordinate" ) diff --git a/agent/consul/state/coordinate_test.go b/agent/consul/state/coordinate_test.go index b2fe8633e6..70e84a6bdc 100644 --- a/agent/consul/state/coordinate_test.go +++ b/agent/consul/state/coordinate_test.go @@ -6,7 +6,7 @@ import ( "reflect" "testing" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/go-memdb" "github.com/hashicorp/serf/coordinate" ) diff --git a/agent/consul/state/kvs.go b/agent/consul/state/kvs.go index d282ec3a42..f4103bb04d 100644 --- a/agent/consul/state/kvs.go +++ b/agent/consul/state/kvs.go @@ -5,7 +5,7 @@ import ( "strings" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/go-memdb" ) diff --git a/agent/consul/state/kvs_test.go b/agent/consul/state/kvs_test.go index 36db7ac7b9..1ff2d6394f 100644 --- a/agent/consul/state/kvs_test.go +++ b/agent/consul/state/kvs_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/go-memdb" ) diff --git a/agent/consul/state/prepared_query.go b/agent/consul/state/prepared_query.go index c610be5c72..73ebf1db9a 100644 --- a/agent/consul/state/prepared_query.go +++ b/agent/consul/state/prepared_query.go @@ -5,7 +5,7 @@ import ( "regexp" "github.com/hashicorp/consul/agent/consul/prepared_query" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/go-memdb" ) diff --git a/agent/consul/state/prepared_query_index_test.go b/agent/consul/state/prepared_query_index_test.go index 46dc8cf538..b81a612676 100644 --- a/agent/consul/state/prepared_query_index_test.go +++ b/agent/consul/state/prepared_query_index_test.go @@ -3,7 +3,7 @@ package state import ( "testing" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" ) // Indexer is a global indexer to use for tests since there is no state. diff --git a/agent/consul/state/prepared_query_test.go b/agent/consul/state/prepared_query_test.go index 49d7061774..808fa4a4dd 100644 --- a/agent/consul/state/prepared_query_test.go +++ b/agent/consul/state/prepared_query_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/go-memdb" ) diff --git a/agent/consul/state/session.go b/agent/consul/state/session.go index b4135f2407..ed958d827a 100644 --- a/agent/consul/state/session.go +++ b/agent/consul/state/session.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/go-memdb" ) diff --git a/agent/consul/state/session_test.go b/agent/consul/state/session_test.go index 220563fd72..1e638f6ece 100644 --- a/agent/consul/state/session_test.go +++ b/agent/consul/state/session_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/types" "github.com/hashicorp/go-memdb" diff --git a/agent/consul/state/state_store_test.go b/agent/consul/state/state_store_test.go index c8bcab4b3e..c875d40d9a 100644 --- a/agent/consul/state/state_store_test.go +++ b/agent/consul/state/state_store_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/types" "github.com/hashicorp/go-memdb" ) diff --git a/agent/consul/state/txn.go b/agent/consul/state/txn.go index 191d594708..9c8fdd5ed7 100644 --- a/agent/consul/state/txn.go +++ b/agent/consul/state/txn.go @@ -3,7 +3,7 @@ package state import ( "fmt" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/go-memdb" ) diff --git a/agent/consul/state/txn_test.go b/agent/consul/state/txn_test.go index 17cd1da581..29d0f31bd5 100644 --- a/agent/consul/state/txn_test.go +++ b/agent/consul/state/txn_test.go @@ -5,7 +5,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" ) diff --git a/agent/consul/stats_fetcher.go b/agent/consul/stats_fetcher.go index 291933f701..e6f91821b2 100644 --- a/agent/consul/stats_fetcher.go +++ b/agent/consul/stats_fetcher.go @@ -6,8 +6,8 @@ import ( "sync" "github.com/hashicorp/consul/agent/consul/agent" - "github.com/hashicorp/consul/agent/consul/structs" "github.com/hashicorp/consul/agent/pool" + "github.com/hashicorp/consul/agent/structs" ) // StatsFetcher has two functions for autopilot. First, lets us fetch all the diff --git a/agent/consul/status_endpoint.go b/agent/consul/status_endpoint.go index ccdf19c40a..33b7b48f5a 100644 --- a/agent/consul/status_endpoint.go +++ b/agent/consul/status_endpoint.go @@ -4,7 +4,7 @@ import ( "fmt" "strconv" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" ) // Status endpoint is used to check on server status diff --git a/agent/consul/txn_endpoint.go b/agent/consul/txn_endpoint.go index e38882d021..9800bd5335 100644 --- a/agent/consul/txn_endpoint.go +++ b/agent/consul/txn_endpoint.go @@ -6,7 +6,7 @@ import ( "github.com/armon/go-metrics" "github.com/hashicorp/consul/acl" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" ) // Txn endpoint is used to perform multi-object atomic transactions. diff --git a/agent/consul/txn_endpoint_test.go b/agent/consul/txn_endpoint_test.go index 0a885446d5..c7ed5f5f56 100644 --- a/agent/consul/txn_endpoint_test.go +++ b/agent/consul/txn_endpoint_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/net-rpc-msgpackrpc" diff --git a/agent/coordinate_endpoint.go b/agent/coordinate_endpoint.go index bf9f38713d..922edbb84e 100644 --- a/agent/coordinate_endpoint.go +++ b/agent/coordinate_endpoint.go @@ -5,7 +5,7 @@ import ( "net/http" "sort" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" ) // coordinateDisabled handles all the endpoints when coordinates are not enabled, diff --git a/agent/coordinate_endpoint_test.go b/agent/coordinate_endpoint_test.go index 449d55ae2e..010550c6b5 100644 --- a/agent/coordinate_endpoint_test.go +++ b/agent/coordinate_endpoint_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/serf/coordinate" ) diff --git a/agent/dns.go b/agent/dns.go index 24227553a9..3868939bdc 100644 --- a/agent/dns.go +++ b/agent/dns.go @@ -13,7 +13,7 @@ import ( "github.com/armon/go-metrics" "github.com/hashicorp/consul/agent/consul" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/lib" "github.com/miekg/dns" ) diff --git a/agent/dns_test.go b/agent/dns_test.go index 152f5f237b..f6a6e73d92 100644 --- a/agent/dns_test.go +++ b/agent/dns_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/testutil/retry" diff --git a/agent/event_endpoint.go b/agent/event_endpoint.go index 3eedb32fc2..3d949cd45c 100644 --- a/agent/event_endpoint.go +++ b/agent/event_endpoint.go @@ -9,7 +9,7 @@ import ( "strings" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" ) const ( diff --git a/agent/event_endpoint_test.go b/agent/event_endpoint_test.go index d842b64fd5..6507b489cd 100644 --- a/agent/event_endpoint_test.go +++ b/agent/event_endpoint_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/testutil/retry" ) diff --git a/agent/health_endpoint.go b/agent/health_endpoint.go index 1e46956e42..5dc34d6101 100644 --- a/agent/health_endpoint.go +++ b/agent/health_endpoint.go @@ -6,7 +6,7 @@ import ( "strconv" "strings" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" ) diff --git a/agent/health_endpoint_test.go b/agent/health_endpoint_test.go index 9dcbbff4fd..33011fcbb7 100644 --- a/agent/health_endpoint_test.go +++ b/agent/health_endpoint_test.go @@ -9,7 +9,7 @@ import ( "reflect" "testing" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/serf/coordinate" diff --git a/agent/http.go b/agent/http.go index 8806ee2d2c..5b5a7d532c 100644 --- a/agent/http.go +++ b/agent/http.go @@ -12,7 +12,7 @@ import ( "time" "github.com/armon/go-metrics" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/mitchellh/mapstructure" ) diff --git a/agent/http_test.go b/agent/http_test.go index 13567ab6ab..81dfe19777 100644 --- a/agent/http_test.go +++ b/agent/http_test.go @@ -18,7 +18,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/testutil" "github.com/hashicorp/go-cleanhttp" ) diff --git a/agent/keyring.go b/agent/keyring.go index 18b2bc3736..8f00853dd4 100644 --- a/agent/keyring.go +++ b/agent/keyring.go @@ -9,7 +9,7 @@ import ( "path/filepath" "github.com/hashicorp/consul/agent/consul" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/memberlist" "github.com/hashicorp/serf/serf" ) diff --git a/agent/kvs_endpoint.go b/agent/kvs_endpoint.go index c271d64d48..5a1604c157 100644 --- a/agent/kvs_endpoint.go +++ b/agent/kvs_endpoint.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" ) diff --git a/agent/kvs_endpoint_test.go b/agent/kvs_endpoint_test.go index f03a637cfb..6977679a0f 100644 --- a/agent/kvs_endpoint_test.go +++ b/agent/kvs_endpoint_test.go @@ -8,7 +8,7 @@ import ( "reflect" "testing" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" ) func TestKVSEndpoint_PUT_GET_DELETE(t *testing.T) { diff --git a/agent/local.go b/agent/local.go index 57bb944ff1..bf4ab4bb2f 100644 --- a/agent/local.go +++ b/agent/local.go @@ -9,7 +9,7 @@ import ( "sync/atomic" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/agent/token" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/lib" diff --git a/agent/local_test.go b/agent/local_test.go index 98406a3763..5ff8b1c611 100644 --- a/agent/local_test.go +++ b/agent/local_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/agent/token" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/testutil/retry" diff --git a/agent/operator_endpoint.go b/agent/operator_endpoint.go index 5b777da373..900dd65dd3 100644 --- a/agent/operator_endpoint.go +++ b/agent/operator_endpoint.go @@ -7,7 +7,7 @@ import ( "strings" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" multierror "github.com/hashicorp/go-multierror" "github.com/hashicorp/raft" diff --git a/agent/operator_endpoint_test.go b/agent/operator_endpoint_test.go index d0e5debb73..c0da418d73 100644 --- a/agent/operator_endpoint_test.go +++ b/agent/operator_endpoint_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/testutil/retry" ) diff --git a/agent/prepared_query_endpoint.go b/agent/prepared_query_endpoint.go index 60a68074b2..f9a08b5993 100644 --- a/agent/prepared_query_endpoint.go +++ b/agent/prepared_query_endpoint.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/hashicorp/consul/agent/consul" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" ) const ( diff --git a/agent/prepared_query_endpoint_test.go b/agent/prepared_query_endpoint_test.go index 5ae6f43926..3f41878eeb 100644 --- a/agent/prepared_query_endpoint_test.go +++ b/agent/prepared_query_endpoint_test.go @@ -9,7 +9,7 @@ import ( "reflect" "testing" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" ) // MockPreparedQuery is a fake endpoint that we inject into the Consul server diff --git a/agent/remote_exec.go b/agent/remote_exec.go index eda398e7eb..e2112922e8 100644 --- a/agent/remote_exec.go +++ b/agent/remote_exec.go @@ -12,7 +12,7 @@ import ( "syscall" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" ) diff --git a/agent/remote_exec_test.go b/agent/remote_exec_test.go index 3b161953ad..e36bb8dc98 100644 --- a/agent/remote_exec_test.go +++ b/agent/remote_exec_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/go-uuid" ) diff --git a/agent/session_endpoint.go b/agent/session_endpoint.go index 685b30bc92..7378ed9379 100644 --- a/agent/session_endpoint.go +++ b/agent/session_endpoint.go @@ -6,7 +6,7 @@ import ( "strings" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/types" ) diff --git a/agent/session_endpoint_test.go b/agent/session_endpoint_test.go index ce3b5a6f7c..1088a2c923 100644 --- a/agent/session_endpoint_test.go +++ b/agent/session_endpoint_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/types" ) diff --git a/agent/snapshot_endpoint.go b/agent/snapshot_endpoint.go index e6abfa1d25..b5bd451607 100644 --- a/agent/snapshot_endpoint.go +++ b/agent/snapshot_endpoint.go @@ -4,7 +4,7 @@ import ( "bytes" "net/http" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" ) // Snapshot handles requests to take and restore snapshots. This uses a special diff --git a/agent/consul/structs/acl.go b/agent/structs/acl.go similarity index 100% rename from agent/consul/structs/acl.go rename to agent/structs/acl.go diff --git a/agent/consul/structs/acl_test.go b/agent/structs/acl_test.go similarity index 100% rename from agent/consul/structs/acl_test.go rename to agent/structs/acl_test.go diff --git a/agent/consul/structs/catalog.go b/agent/structs/catalog.go similarity index 100% rename from agent/consul/structs/catalog.go rename to agent/structs/catalog.go diff --git a/agent/consul/structs/check_definition.go b/agent/structs/check_definition.go similarity index 100% rename from agent/consul/structs/check_definition.go rename to agent/structs/check_definition.go diff --git a/agent/consul/structs/check_definition_test.go b/agent/structs/check_definition_test.go similarity index 100% rename from agent/consul/structs/check_definition_test.go rename to agent/structs/check_definition_test.go diff --git a/agent/consul/structs/check_type.go b/agent/structs/check_type.go similarity index 100% rename from agent/consul/structs/check_type.go rename to agent/structs/check_type.go diff --git a/agent/consul/structs/operator.go b/agent/structs/operator.go similarity index 100% rename from agent/consul/structs/operator.go rename to agent/structs/operator.go diff --git a/agent/consul/structs/operator_test.go b/agent/structs/operator_test.go similarity index 100% rename from agent/consul/structs/operator_test.go rename to agent/structs/operator_test.go diff --git a/agent/consul/structs/prepared_query.go b/agent/structs/prepared_query.go similarity index 100% rename from agent/consul/structs/prepared_query.go rename to agent/structs/prepared_query.go diff --git a/agent/consul/structs/prepared_query_test.go b/agent/structs/prepared_query_test.go similarity index 100% rename from agent/consul/structs/prepared_query_test.go rename to agent/structs/prepared_query_test.go diff --git a/agent/consul/structs/service_definition.go b/agent/structs/service_definition.go similarity index 100% rename from agent/consul/structs/service_definition.go rename to agent/structs/service_definition.go diff --git a/agent/consul/structs/service_definition_test.go b/agent/structs/service_definition_test.go similarity index 100% rename from agent/consul/structs/service_definition_test.go rename to agent/structs/service_definition_test.go diff --git a/agent/consul/structs/snapshot.go b/agent/structs/snapshot.go similarity index 100% rename from agent/consul/structs/snapshot.go rename to agent/structs/snapshot.go diff --git a/agent/consul/structs/structs.go b/agent/structs/structs.go similarity index 100% rename from agent/consul/structs/structs.go rename to agent/structs/structs.go diff --git a/agent/consul/structs/structs_test.go b/agent/structs/structs_test.go similarity index 100% rename from agent/consul/structs/structs_test.go rename to agent/structs/structs_test.go diff --git a/agent/consul/structs/txn.go b/agent/structs/txn.go similarity index 100% rename from agent/consul/structs/txn.go rename to agent/structs/txn.go diff --git a/agent/testagent.go b/agent/testagent.go index 8269d7d335..de2306fa96 100644 --- a/agent/testagent.go +++ b/agent/testagent.go @@ -16,7 +16,7 @@ import ( "time" "github.com/hashicorp/consul/agent/consul" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/logger" "github.com/hashicorp/consul/testutil/retry" diff --git a/agent/translate_addr.go b/agent/translate_addr.go index 8c3fc4ef98..f93a685c04 100644 --- a/agent/translate_addr.go +++ b/agent/translate_addr.go @@ -3,7 +3,7 @@ package agent import ( "fmt" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" ) // TranslateAddress is used to provide the final, translated address for a node, diff --git a/agent/txn_endpoint.go b/agent/txn_endpoint.go index 961994a0ff..b38bd2d062 100644 --- a/agent/txn_endpoint.go +++ b/agent/txn_endpoint.go @@ -6,7 +6,7 @@ import ( "net/http" "strings" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" ) diff --git a/agent/txn_endpoint_test.go b/agent/txn_endpoint_test.go index 91c7bed45c..a8241abd8a 100644 --- a/agent/txn_endpoint_test.go +++ b/agent/txn_endpoint_test.go @@ -9,7 +9,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" ) func TestTxnEndpoint_Bad_JSON(t *testing.T) { diff --git a/agent/ui_endpoint.go b/agent/ui_endpoint.go index 22ae02e85d..b248480e98 100644 --- a/agent/ui_endpoint.go +++ b/agent/ui_endpoint.go @@ -6,7 +6,7 @@ import ( "sort" "strings" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" ) diff --git a/agent/ui_endpoint_test.go b/agent/ui_endpoint_test.go index f1c1bae545..d780d9147a 100644 --- a/agent/ui_endpoint_test.go +++ b/agent/ui_endpoint_test.go @@ -12,7 +12,7 @@ import ( "reflect" "testing" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/testutil" "github.com/hashicorp/go-cleanhttp" diff --git a/agent/user_event.go b/agent/user_event.go index 5d27135b73..9506c6c14f 100644 --- a/agent/user_event.go +++ b/agent/user_event.go @@ -4,7 +4,7 @@ import ( "fmt" "regexp" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/go-uuid" ) diff --git a/agent/user_event_test.go b/agent/user_event_test.go index fdafb0bd3e..f10fd1ef20 100644 --- a/agent/user_event_test.go +++ b/agent/user_event_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/testutil/retry" ) diff --git a/command/agent.go b/command/agent.go index fc31a53b7c..683c8e4b7e 100644 --- a/command/agent.go +++ b/command/agent.go @@ -17,7 +17,7 @@ import ( "github.com/armon/go-metrics/circonus" "github.com/armon/go-metrics/datadog" "github.com/hashicorp/consul/agent" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/configutil" "github.com/hashicorp/consul/ipaddr" "github.com/hashicorp/consul/lib" diff --git a/command/maint_test.go b/command/maint_test.go index b9e7bfc8be..11b799507d 100644 --- a/command/maint_test.go +++ b/command/maint_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/hashicorp/consul/agent" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/mitchellh/cli" ) diff --git a/command/operator_autopilot_set_test.go b/command/operator_autopilot_set_test.go index 3c55070efe..cc51e81fd2 100644 --- a/command/operator_autopilot_set_test.go +++ b/command/operator_autopilot_set_test.go @@ -6,7 +6,7 @@ import ( "time" "github.com/hashicorp/consul/agent" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/mitchellh/cli" ) diff --git a/command/rtt_test.go b/command/rtt_test.go index 13e1598902..76e3876f02 100644 --- a/command/rtt_test.go +++ b/command/rtt_test.go @@ -7,7 +7,7 @@ import ( "time" "github.com/hashicorp/consul/agent" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/testutil/retry" "github.com/hashicorp/serf/coordinate" "github.com/mitchellh/cli" diff --git a/testrpc/wait.go b/testrpc/wait.go index 1a5cf8c841..ba0c4afb42 100644 --- a/testrpc/wait.go +++ b/testrpc/wait.go @@ -3,7 +3,7 @@ package testrpc import ( "testing" - "github.com/hashicorp/consul/agent/consul/structs" + "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/testutil/retry" ) From c395599ceaf8aca07d19948ef7f9f35ab437d386 Mon Sep 17 00:00:00 2001 From: Frank Schroeder Date: Thu, 6 Jul 2017 12:40:54 +0200 Subject: [PATCH 2/3] agent: move agent/consul/servers to agent/router --- agent/consul/client.go | 24 +++++++++---------- agent/consul/client_test.go | 12 +++++----- agent/consul/flood.go | 6 ++--- agent/consul/server.go | 10 ++++---- agent/{consul/servers => router}/manager.go | 2 +- .../manager_internal_test.go | 2 +- .../servers => router}/manager_test.go | 14 +++++------ agent/{consul/servers => router}/router.go | 2 +- .../{consul/servers => router}/router_test.go | 2 +- .../servers => router}/serf_adapter.go | 2 +- .../servers => router}/serf_flooder.go | 2 +- 11 files changed, 39 insertions(+), 39 deletions(-) rename agent/{consul/servers => router}/manager.go (99%) rename agent/{consul/servers => router}/manager_internal_test.go (99%) rename agent/{consul/servers => router}/manager_test.go (95%) rename agent/{consul/servers => router}/router.go (99%) rename agent/{consul/servers => router}/router_test.go (99%) rename agent/{consul/servers => router}/serf_adapter.go (99%) rename agent/{consul/servers => router}/serf_flooder.go (99%) diff --git a/agent/consul/client.go b/agent/consul/client.go index 8e23e4b884..dc562e1313 100644 --- a/agent/consul/client.go +++ b/agent/consul/client.go @@ -12,8 +12,8 @@ import ( "time" "github.com/hashicorp/consul/agent/consul/agent" - "github.com/hashicorp/consul/agent/consul/servers" "github.com/hashicorp/consul/agent/pool" + "github.com/hashicorp/consul/agent/router" "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/serf/coordinate" @@ -52,9 +52,9 @@ type Client struct { // Connection pool to consul servers connPool *pool.ConnPool - // servers is responsible for the selection and maintenance of + // routers is responsible for the selection and maintenance of // Consul servers this agent uses for RPC requests - servers *servers.Manager + routers *router.Manager // eventCh is used to receive events from the // serf cluster in the datacenter @@ -140,8 +140,8 @@ func NewClientLogger(config *Config, logger *log.Logger) (*Client, error) { } // Start maintenance task for servers - c.servers = servers.New(c.logger, c.shutdownCh, c.serf, c.connPool) - go c.servers.Start() + c.routers = router.New(c.logger, c.shutdownCh, c.serf, c.connPool) + go c.routers.Start() return c, nil } @@ -285,7 +285,7 @@ func (c *Client) nodeJoin(me serf.MemberEvent) { continue } c.logger.Printf("[INFO] consul: adding server %s", parts) - c.servers.AddServer(parts) + c.routers.AddServer(parts) // Trigger the callback if c.config.ServerUp != nil { @@ -302,7 +302,7 @@ func (c *Client) nodeFail(me serf.MemberEvent) { continue } c.logger.Printf("[INFO] consul: removing server %s", parts) - c.servers.RemoveServer(parts) + c.routers.RemoveServer(parts) } } @@ -336,14 +336,14 @@ func (c *Client) localEvent(event serf.UserEvent) { // RPC is used to forward an RPC call to a consul server, or fail if no servers func (c *Client) RPC(method string, args interface{}, reply interface{}) error { - server := c.servers.FindServer() + server := c.routers.FindServer() if server == nil { return structs.ErrNoServers } // Forward to remote Consul if err := c.connPool.RPC(c.config.Datacenter, server.Addr, server.Version, method, server.UseTLS, args, reply); err != nil { - c.servers.NotifyFailedServer(server) + c.routers.NotifyFailedServer(server) c.logger.Printf("[ERR] consul: RPC failed to server %s: %v", server.Addr, err) return err } @@ -358,7 +358,7 @@ func (c *Client) SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io replyFn structs.SnapshotReplyFn) error { // Locate a server to make the request to. - server := c.servers.FindServer() + server := c.routers.FindServer() if server == nil { return structs.ErrNoServers } @@ -395,7 +395,7 @@ func (c *Client) SnapshotRPC(args *structs.SnapshotRequest, in io.Reader, out io // Stats is used to return statistics for debugging and insight // for various sub-systems func (c *Client) Stats() map[string]map[string]string { - numServers := c.servers.NumServers() + numServers := c.routers.NumServers() toString := func(v uint64) string { return strconv.FormatUint(v, 10) @@ -412,7 +412,7 @@ func (c *Client) Stats() map[string]map[string]string { } func (c *Client) ServerAddrs() map[string]string { - return c.servers.GetServerAddrs() + return c.routers.GetServerAddrs() } // GetLANCoordinate returns the network coordinate of the current node, as diff --git a/agent/consul/client_test.go b/agent/consul/client_test.go index e5a79d1aa6..ba29912750 100644 --- a/agent/consul/client_test.go +++ b/agent/consul/client_test.go @@ -84,7 +84,7 @@ func TestClient_JoinLAN(t *testing.T) { // Try to join joinLAN(t, c1, s1) retry.Run(t, func(r *retry.R) { - if got, want := c1.servers.NumServers(), 1; got != want { + if got, want := c1.routers.NumServers(), 1; got != want { r.Fatalf("got %d servers want %d", got, want) } if got, want := len(s1.LANMembers()), 2; got != want { @@ -254,7 +254,7 @@ func TestClient_RPC_ConsulServerPing(t *testing.T) { } // Sleep to allow Serf to sync, shuffle, and let the shuffle complete - c.servers.ResetRebalanceTimer() + c.routers.ResetRebalanceTimer() time.Sleep(time.Second) if len(c.LANMembers()) != numServers+numClients { @@ -270,7 +270,7 @@ func TestClient_RPC_ConsulServerPing(t *testing.T) { var pingCount int for range servers { time.Sleep(200 * time.Millisecond) - s := c.servers.FindServer() + s := c.routers.FindServer() ok, err := c.connPool.Ping(s.Datacenter, s.Addr, s.Version, s.UseTLS) if !ok { t.Errorf("Unable to ping server %v: %s", s.String(), err) @@ -279,7 +279,7 @@ func TestClient_RPC_ConsulServerPing(t *testing.T) { // Artificially fail the server in order to rotate the server // list - c.servers.NotifyFailedServer(s) + c.routers.NotifyFailedServer(s) } if pingCount != numServers { @@ -354,7 +354,7 @@ func TestClient_SnapshotRPC(t *testing.T) { // Wait until we've got a healthy server. retry.Run(t, func(r *retry.R) { - if got, want := c1.servers.NumServers(), 1; got != want { + if got, want := c1.routers.NumServers(), 1; got != want { r.Fatalf("got %d servers want %d", got, want) } }) @@ -413,7 +413,7 @@ func TestClient_SnapshotRPC_TLS(t *testing.T) { } // Wait until we've got a healthy server. - if got, want := c1.servers.NumServers(), 1; got != want { + if got, want := c1.routers.NumServers(), 1; got != want { r.Fatalf("got %d servers want %d", got, want) } }) diff --git a/agent/consul/flood.go b/agent/consul/flood.go index 12705c8b9d..0e233eab9c 100644 --- a/agent/consul/flood.go +++ b/agent/consul/flood.go @@ -3,7 +3,7 @@ package consul import ( "time" - "github.com/hashicorp/consul/agent/consul/servers" + "github.com/hashicorp/consul/agent/router" "github.com/hashicorp/serf/serf" ) @@ -24,7 +24,7 @@ func (s *Server) FloodNotify() { // Flood is a long-running goroutine that floods servers from the LAN to the // given global Serf instance, such as the WAN. This will exit once either of // the Serf instances are shut down. -func (s *Server) Flood(portFn servers.FloodPortFn, global *serf.Serf) { +func (s *Server) Flood(portFn router.FloodPortFn, global *serf.Serf) { s.floodLock.Lock() floodCh := make(chan struct{}) s.floodCh = append(s.floodCh, floodCh) @@ -61,6 +61,6 @@ func (s *Server) Flood(portFn servers.FloodPortFn, global *serf.Serf) { } FLOOD: - servers.FloodJoins(s.logger, portFn, s.config.Datacenter, s.serfLAN, global) + router.FloodJoins(s.logger, portFn, s.config.Datacenter, s.serfLAN, global) } } diff --git a/agent/consul/server.go b/agent/consul/server.go index 5c89e9e051..f72795a107 100644 --- a/agent/consul/server.go +++ b/agent/consul/server.go @@ -19,9 +19,9 @@ import ( "github.com/hashicorp/consul/acl" "github.com/hashicorp/consul/agent/consul/agent" - "github.com/hashicorp/consul/agent/consul/servers" "github.com/hashicorp/consul/agent/consul/state" "github.com/hashicorp/consul/agent/pool" + "github.com/hashicorp/consul/agent/router" "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/agent/token" "github.com/hashicorp/consul/lib" @@ -154,7 +154,7 @@ type Server struct { // router is used to map out Consul servers in the WAN and in Consul // Enterprise user-defined areas. - router *servers.Router + router *router.Router // Listener is used to listen for incoming connections Listener net.Listener @@ -181,7 +181,7 @@ type Server struct { sessionTimers *SessionTimers // statsFetcher is used by autopilot to check the status of the other - // Consul servers. + // Consul router. statsFetcher *StatsFetcher // reassertLeaderCh is used to signal the leader loop should re-run @@ -298,7 +298,7 @@ func NewServerLogger(config *Config, logger *log.Logger, tokens *token.Store) (* localConsuls: make(map[raft.ServerAddress]*agent.Server), logger: logger, reconcileCh: make(chan serf.Member, 32), - router: servers.NewRouter(logger, config.Datacenter), + router: router.NewRouter(logger, config.Datacenter), rpcServer: rpc.NewServer(), rpcTLS: incomingTLS, reassertLeaderCh: make(chan chan error), @@ -382,7 +382,7 @@ func NewServerLogger(config *Config, logger *log.Logger, tokens *token.Store) (* s.Shutdown() return nil, fmt.Errorf("Failed to add WAN serf route: %v", err) } - go servers.HandleSerfEvents(s.logger, s.router, types.AreaWAN, s.serfWAN.ShutdownCh(), s.eventChWAN) + go router.HandleSerfEvents(s.logger, s.router, types.AreaWAN, s.serfWAN.ShutdownCh(), s.eventChWAN) // Fire up the LAN <-> WAN join flooder. portFn := func(s *agent.Server) (int, bool) { diff --git a/agent/consul/servers/manager.go b/agent/router/manager.go similarity index 99% rename from agent/consul/servers/manager.go rename to agent/router/manager.go index 092efadd7b..497191ba80 100644 --- a/agent/consul/servers/manager.go +++ b/agent/router/manager.go @@ -3,7 +3,7 @@ // client's perspective (i.e. a list of servers that a client talks with for // RPCs). The servers package does not provide any API guarantees and should // be called only by `hashicorp/consul`. -package servers +package router import ( "log" diff --git a/agent/consul/servers/manager_internal_test.go b/agent/router/manager_internal_test.go similarity index 99% rename from agent/consul/servers/manager_internal_test.go rename to agent/router/manager_internal_test.go index c6c993697d..c11a3c49e8 100644 --- a/agent/consul/servers/manager_internal_test.go +++ b/agent/router/manager_internal_test.go @@ -1,4 +1,4 @@ -package servers +package router import ( "bytes" diff --git a/agent/consul/servers/manager_test.go b/agent/router/manager_test.go similarity index 95% rename from agent/consul/servers/manager_test.go rename to agent/router/manager_test.go index 8c8041bd5a..35e17d463f 100644 --- a/agent/consul/servers/manager_test.go +++ b/agent/router/manager_test.go @@ -1,4 +1,4 @@ -package servers_test +package router_test import ( "fmt" @@ -10,7 +10,7 @@ import ( "testing" "github.com/hashicorp/consul/agent/consul/agent" - "github.com/hashicorp/consul/agent/consul/servers" + "github.com/hashicorp/consul/agent/router" ) type fauxConnPool struct { @@ -34,17 +34,17 @@ func (s *fauxSerf) NumNodes() int { return 16384 } -func testManager() (m *servers.Manager) { +func testManager() (m *router.Manager) { logger := log.New(os.Stderr, "", log.LstdFlags) shutdownCh := make(chan struct{}) - m = servers.New(logger, shutdownCh, &fauxSerf{}, &fauxConnPool{}) + m = router.New(logger, shutdownCh, &fauxSerf{}, &fauxConnPool{}) return m } -func testManagerFailProb(failPct float64) (m *servers.Manager) { +func testManagerFailProb(failPct float64) (m *router.Manager) { logger := log.New(os.Stderr, "", log.LstdFlags) shutdownCh := make(chan struct{}) - m = servers.New(logger, shutdownCh, &fauxSerf{}, &fauxConnPool{failPct: failPct}) + m = router.New(logger, shutdownCh, &fauxSerf{}, &fauxConnPool{failPct: failPct}) return m } @@ -169,7 +169,7 @@ func TestServers_FindServer(t *testing.T) { func TestServers_New(t *testing.T) { logger := log.New(os.Stderr, "", log.LstdFlags) shutdownCh := make(chan struct{}) - m := servers.New(logger, shutdownCh, &fauxSerf{}, &fauxConnPool{}) + m := router.New(logger, shutdownCh, &fauxSerf{}, &fauxConnPool{}) if m == nil { t.Fatalf("Manager nil") } diff --git a/agent/consul/servers/router.go b/agent/router/router.go similarity index 99% rename from agent/consul/servers/router.go rename to agent/router/router.go index b295cca83a..ac043d9393 100644 --- a/agent/consul/servers/router.go +++ b/agent/router/router.go @@ -1,4 +1,4 @@ -package servers +package router import ( "fmt" diff --git a/agent/consul/servers/router_test.go b/agent/router/router_test.go similarity index 99% rename from agent/consul/servers/router_test.go rename to agent/router/router_test.go index c6f430079c..f6cf2a08ed 100644 --- a/agent/consul/servers/router_test.go +++ b/agent/router/router_test.go @@ -1,4 +1,4 @@ -package servers +package router import ( "fmt" diff --git a/agent/consul/servers/serf_adapter.go b/agent/router/serf_adapter.go similarity index 99% rename from agent/consul/servers/serf_adapter.go rename to agent/router/serf_adapter.go index 052696b4ac..768834c0da 100644 --- a/agent/consul/servers/serf_adapter.go +++ b/agent/router/serf_adapter.go @@ -1,4 +1,4 @@ -package servers +package router import ( "log" diff --git a/agent/consul/servers/serf_flooder.go b/agent/router/serf_flooder.go similarity index 99% rename from agent/consul/servers/serf_flooder.go rename to agent/router/serf_flooder.go index bf49aee67b..f13e48fcf3 100644 --- a/agent/consul/servers/serf_flooder.go +++ b/agent/router/serf_flooder.go @@ -1,4 +1,4 @@ -package servers +package router import ( "fmt" From 7cff50a4df02be8c2a63233c4c821ef3fdb1982c Mon Sep 17 00:00:00 2001 From: Frank Schroeder Date: Thu, 6 Jul 2017 12:48:37 +0200 Subject: [PATCH 3/3] agent: move agent/consul/agent to agent/metadata --- agent/consul/autopilot.go | 12 +++--- agent/consul/client.go | 6 +-- agent/consul/leader.go | 14 +++---- agent/consul/merge.go | 6 +-- agent/consul/operator_raft_endpoint.go | 4 +- agent/consul/rpc.go | 8 ++-- agent/consul/serf.go | 10 ++--- agent/consul/server.go | 10 ++--- agent/consul/server_test.go | 4 +- agent/consul/stats_fetcher.go | 8 ++-- agent/consul/stats_fetcher_test.go | 6 +-- agent/consul/util.go | 4 +- agent/{consul/agent => metadata}/server.go | 2 +- .../server_internal_test.go | 2 +- .../{consul/agent => metadata}/server_test.go | 30 +++++++------- agent/router/manager.go | 34 ++++++++-------- agent/router/manager_internal_test.go | 22 +++++----- agent/router/manager_test.go | 40 +++++++++---------- agent/router/router.go | 22 +++++----- agent/router/serf_adapter.go | 6 +-- agent/router/serf_flooder.go | 10 ++--- 21 files changed, 130 insertions(+), 130 deletions(-) rename agent/{consul/agent => metadata}/server.go (99%) rename agent/{consul/agent => metadata}/server_internal_test.go (98%) rename agent/{consul/agent => metadata}/server_test.go (88%) diff --git a/agent/consul/autopilot.go b/agent/consul/autopilot.go index fe02256da3..ba6d68a69c 100644 --- a/agent/consul/autopilot.go +++ b/agent/consul/autopilot.go @@ -8,7 +8,7 @@ import ( "time" "github.com/armon/go-metrics" - "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/metadata" "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/go-version" "github.com/hashicorp/raft" @@ -90,7 +90,7 @@ func (s *Server) pruneDeadServers(autopilotConfig *structs.AutopilotConfig) erro } for _, member := range s.serfLAN.Members() { - valid, parts := agent.IsConsulServer(member) + valid, parts := metadata.IsConsulServer(member) if valid { // Remove this server from the stale list; it has a serf entry @@ -275,13 +275,13 @@ func (s *Server) updateClusterHealth() error { } // Get the the serf members which are Consul servers - serverMap := make(map[string]*agent.Server) + serverMap := make(map[string]*metadata.Server) for _, member := range s.LANMembers() { if member.Status == serf.StatusLeft { continue } - valid, parts := agent.IsConsulServer(member) + valid, parts := metadata.IsConsulServer(member) if valid { serverMap[parts.ID] = parts } @@ -297,7 +297,7 @@ func (s *Server) updateClusterHealth() error { // consistent of a sample as possible. We capture the leader's index // here as well so it roughly lines up with the same point in time. targetLastIndex := s.raft.LastIndex() - var fetchList []*agent.Server + var fetchList []*metadata.Server for _, server := range servers { if parts, ok := serverMap[string(server.ID)]; ok { fetchList = append(fetchList, parts) @@ -377,7 +377,7 @@ func (s *Server) updateClusterHealth() error { // updateServerHealth computes the resulting health of the server based on its // fetched stats and the state of the leader. func (s *Server) updateServerHealth(health *structs.ServerHealth, - server *agent.Server, stats *structs.ServerStats, + server *metadata.Server, stats *structs.ServerStats, autopilotConf *structs.AutopilotConfig, targetLastIndex uint64) error { health.LastTerm = stats.LastTerm diff --git a/agent/consul/client.go b/agent/consul/client.go index dc562e1313..d669100ff7 100644 --- a/agent/consul/client.go +++ b/agent/consul/client.go @@ -11,7 +11,7 @@ import ( "sync" "time" - "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/metadata" "github.com/hashicorp/consul/agent/pool" "github.com/hashicorp/consul/agent/router" "github.com/hashicorp/consul/agent/structs" @@ -275,7 +275,7 @@ func (c *Client) lanEventHandler() { // nodeJoin is used to handle join events on the serf cluster func (c *Client) nodeJoin(me serf.MemberEvent) { for _, m := range me.Members { - ok, parts := agent.IsConsulServer(m) + ok, parts := metadata.IsConsulServer(m) if !ok { continue } @@ -297,7 +297,7 @@ func (c *Client) nodeJoin(me serf.MemberEvent) { // nodeFail is used to handle fail events on the serf cluster func (c *Client) nodeFail(me serf.MemberEvent) { for _, m := range me.Members { - ok, parts := agent.IsConsulServer(m) + ok, parts := metadata.IsConsulServer(m) if !ok { continue } diff --git a/agent/consul/leader.go b/agent/consul/leader.go index 1d3c60c931..20749b286c 100644 --- a/agent/consul/leader.go +++ b/agent/consul/leader.go @@ -9,7 +9,7 @@ import ( "time" "github.com/armon/go-metrics" - "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/metadata" "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/api" "github.com/hashicorp/consul/types" @@ -440,7 +440,7 @@ func (s *Server) shouldHandleMember(member serf.Member) bool { if valid, dc := isConsulNode(member); valid && dc == s.config.Datacenter { return true } - if valid, parts := agent.IsConsulServer(member); valid && parts.Datacenter == s.config.Datacenter { + if valid, parts := metadata.IsConsulServer(member); valid && parts.Datacenter == s.config.Datacenter { return true } return false @@ -451,7 +451,7 @@ func (s *Server) shouldHandleMember(member serf.Member) bool { func (s *Server) handleAliveMember(member serf.Member) error { // Register consul service if a server var service *structs.NodeService - if valid, parts := agent.IsConsulServer(member); valid { + if valid, parts := metadata.IsConsulServer(member); valid { service = &structs.NodeService{ ID: structs.ConsulServiceID, Service: structs.ConsulServiceName, @@ -595,7 +595,7 @@ func (s *Server) handleDeregisterMember(reason string, member serf.Member) error } // Remove from Raft peers if this was a server - if valid, parts := agent.IsConsulServer(member); valid { + if valid, parts := metadata.IsConsulServer(member); valid { if err := s.removeConsulServer(member, parts.Port); err != nil { return err } @@ -622,7 +622,7 @@ func (s *Server) handleDeregisterMember(reason string, member serf.Member) error } // joinConsulServer is used to try to join another consul server -func (s *Server) joinConsulServer(m serf.Member, parts *agent.Server) error { +func (s *Server) joinConsulServer(m serf.Member, parts *metadata.Server) error { // Do not join ourself if m.Name == s.config.NodeName { return nil @@ -632,7 +632,7 @@ func (s *Server) joinConsulServer(m serf.Member, parts *agent.Server) error { if parts.Bootstrap { members := s.serfLAN.Members() for _, member := range members { - valid, p := agent.IsConsulServer(member) + valid, p := metadata.IsConsulServer(member) if valid && member.Name != m.Name && p.Bootstrap { s.logger.Printf("[ERR] consul: '%v' and '%v' are both in bootstrap mode. Only one node should be in bootstrap mode, not adding Raft peer.", m.Name, member.Name) return nil @@ -732,7 +732,7 @@ func (s *Server) removeConsulServer(m serf.Member, port int) error { return err } - _, parts := agent.IsConsulServer(m) + _, parts := metadata.IsConsulServer(m) // Pick which remove API to use based on how the server was added. for _, server := range configFuture.Configuration().Servers { diff --git a/agent/consul/merge.go b/agent/consul/merge.go index b361772dcd..f1bc295676 100644 --- a/agent/consul/merge.go +++ b/agent/consul/merge.go @@ -3,7 +3,7 @@ package consul import ( "fmt" - "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/metadata" "github.com/hashicorp/consul/types" "github.com/hashicorp/serf/serf" ) @@ -48,7 +48,7 @@ func (md *lanMergeDelegate) NotifyMerge(members []*serf.Member) error { continue } - ok, parts := agent.IsConsulServer(*m) + ok, parts := metadata.IsConsulServer(*m) if ok && parts.Datacenter != md.dc { return fmt.Errorf("Member '%s' part of wrong datacenter '%s'", m.Name, parts.Datacenter) @@ -65,7 +65,7 @@ type wanMergeDelegate struct { func (md *wanMergeDelegate) NotifyMerge(members []*serf.Member) error { for _, m := range members { - ok, _ := agent.IsConsulServer(*m) + ok, _ := metadata.IsConsulServer(*m) if !ok { return fmt.Errorf("Member '%s' is not a server", m.Name) } diff --git a/agent/consul/operator_raft_endpoint.go b/agent/consul/operator_raft_endpoint.go index 84e7369607..dcda6eb994 100644 --- a/agent/consul/operator_raft_endpoint.go +++ b/agent/consul/operator_raft_endpoint.go @@ -4,7 +4,7 @@ import ( "fmt" "net" - "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/metadata" "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/raft" "github.com/hashicorp/serf/serf" @@ -35,7 +35,7 @@ func (op *Operator) RaftGetConfiguration(args *structs.DCSpecificRequest, reply // Index the Consul information about the servers. serverMap := make(map[raft.ServerAddress]serf.Member) for _, member := range op.srv.serfLAN.Members() { - valid, parts := agent.IsConsulServer(member) + valid, parts := metadata.IsConsulServer(member) if !valid { continue } diff --git a/agent/consul/rpc.go b/agent/consul/rpc.go index 3777e08c8a..41a1a6699a 100644 --- a/agent/consul/rpc.go +++ b/agent/consul/rpc.go @@ -9,12 +9,12 @@ import ( "time" "github.com/armon/go-metrics" - "github.com/hashicorp/consul/agent/consul/agent" "github.com/hashicorp/consul/agent/consul/state" + "github.com/hashicorp/consul/agent/metadata" "github.com/hashicorp/consul/agent/pool" "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/lib" - "github.com/hashicorp/go-memdb" + memdb "github.com/hashicorp/go-memdb" "github.com/hashicorp/memberlist" "github.com/hashicorp/net-rpc-msgpackrpc" "github.com/hashicorp/yamux" @@ -225,7 +225,7 @@ CHECK_LEADER: // getLeader returns if the current node is the leader, and if not then it // returns the leader which is potentially nil if the cluster has not yet // elected a leader. -func (s *Server) getLeader() (bool, *agent.Server) { +func (s *Server) getLeader() (bool, *metadata.Server) { // Check if we are the leader if s.IsLeader() { return true, nil @@ -247,7 +247,7 @@ func (s *Server) getLeader() (bool, *agent.Server) { } // forwardLeader is used to forward an RPC call to the leader, or fail if no leader -func (s *Server) forwardLeader(server *agent.Server, method string, args interface{}, reply interface{}) error { +func (s *Server) forwardLeader(server *metadata.Server, method string, args interface{}, reply interface{}) error { // Handle a missing server if server == nil { return structs.ErrNoLeader diff --git a/agent/consul/serf.go b/agent/consul/serf.go index b9e50e0763..16d3f7be31 100644 --- a/agent/consul/serf.go +++ b/agent/consul/serf.go @@ -4,7 +4,7 @@ import ( "strings" "time" - "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/metadata" "github.com/hashicorp/raft" "github.com/hashicorp/serf/serf" ) @@ -125,7 +125,7 @@ func (s *Server) localEvent(event serf.UserEvent) { // lanNodeJoin is used to handle join events on the LAN pool. func (s *Server) lanNodeJoin(me serf.MemberEvent) { for _, m := range me.Members { - ok, parts := agent.IsConsulServer(m) + ok, parts := metadata.IsConsulServer(m) if !ok { continue } @@ -166,9 +166,9 @@ func (s *Server) maybeBootstrap() { // Scan for all the known servers. members := s.serfLAN.Members() - var servers []agent.Server + var servers []metadata.Server for _, member := range members { - valid, p := agent.IsConsulServer(member) + valid, p := metadata.IsConsulServer(member) if !valid { continue } @@ -265,7 +265,7 @@ func (s *Server) maybeBootstrap() { // lanNodeFailed is used to handle fail events on the LAN pool. func (s *Server) lanNodeFailed(me serf.MemberEvent) { for _, m := range me.Members { - ok, parts := agent.IsConsulServer(m) + ok, parts := metadata.IsConsulServer(m) if !ok { continue } diff --git a/agent/consul/server.go b/agent/consul/server.go index f72795a107..06f843417e 100644 --- a/agent/consul/server.go +++ b/agent/consul/server.go @@ -18,8 +18,8 @@ import ( "time" "github.com/hashicorp/consul/acl" - "github.com/hashicorp/consul/agent/consul/agent" "github.com/hashicorp/consul/agent/consul/state" + "github.com/hashicorp/consul/agent/metadata" "github.com/hashicorp/consul/agent/pool" "github.com/hashicorp/consul/agent/router" "github.com/hashicorp/consul/agent/structs" @@ -28,7 +28,7 @@ import ( "github.com/hashicorp/consul/tlsutil" "github.com/hashicorp/consul/types" "github.com/hashicorp/raft" - "github.com/hashicorp/raft-boltdb" + raftboltdb "github.com/hashicorp/raft-boltdb" "github.com/hashicorp/serf/coordinate" "github.com/hashicorp/serf/serf" ) @@ -125,7 +125,7 @@ type Server struct { // localConsuls is used to track the known consuls // in the local datacenter. Used to do leader forwarding. - localConsuls map[raft.ServerAddress]*agent.Server + localConsuls map[raft.ServerAddress]*metadata.Server localLock sync.RWMutex // Logger uses the provided LogOutput @@ -295,7 +295,7 @@ func NewServerLogger(config *Config, logger *log.Logger, tokens *token.Store) (* connPool: connPool, eventChLAN: make(chan serf.Event, 256), eventChWAN: make(chan serf.Event, 256), - localConsuls: make(map[raft.ServerAddress]*agent.Server), + localConsuls: make(map[raft.ServerAddress]*metadata.Server), logger: logger, reconcileCh: make(chan serf.Member, 32), router: router.NewRouter(logger, config.Datacenter), @@ -385,7 +385,7 @@ func NewServerLogger(config *Config, logger *log.Logger, tokens *token.Store) (* go router.HandleSerfEvents(s.logger, s.router, types.AreaWAN, s.serfWAN.ShutdownCh(), s.eventChWAN) // Fire up the LAN <-> WAN join flooder. - portFn := func(s *agent.Server) (int, bool) { + portFn := func(s *metadata.Server) (int, bool) { if s.WanJoinPort > 0 { return s.WanJoinPort, true } diff --git a/agent/consul/server_test.go b/agent/consul/server_test.go index dda19c484a..21dfe259f2 100644 --- a/agent/consul/server_test.go +++ b/agent/consul/server_test.go @@ -11,7 +11,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/metadata" "github.com/hashicorp/consul/agent/token" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/testutil" @@ -667,7 +667,7 @@ func testVerifyRPC(s1, s2 *Server, t *testing.T) (bool, error) { // Have s2 make an RPC call to s1 s2.localLock.RLock() - var leader *agent.Server + var leader *metadata.Server for _, server := range s2.localConsuls { if server.Name == s1.config.NodeName { leader = server diff --git a/agent/consul/stats_fetcher.go b/agent/consul/stats_fetcher.go index e6f91821b2..25eefb9609 100644 --- a/agent/consul/stats_fetcher.go +++ b/agent/consul/stats_fetcher.go @@ -5,7 +5,7 @@ import ( "log" "sync" - "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/metadata" "github.com/hashicorp/consul/agent/pool" "github.com/hashicorp/consul/agent/structs" ) @@ -39,7 +39,7 @@ func NewStatsFetcher(logger *log.Logger, pool *pool.ConnPool, datacenter string) // cancel this when the context is canceled because we only want one in-flight // RPC to each server, so we let it finish and then clean up the in-flight // tracking. -func (f *StatsFetcher) fetch(server *agent.Server, replyCh chan *structs.ServerStats) { +func (f *StatsFetcher) fetch(server *metadata.Server, replyCh chan *structs.ServerStats) { var args struct{} var reply structs.ServerStats err := f.pool.RPC(f.datacenter, server.Addr, server.Version, "Status.RaftStats", server.UseTLS, &args, &reply) @@ -56,9 +56,9 @@ func (f *StatsFetcher) fetch(server *agent.Server, replyCh chan *structs.ServerS } // Fetch will attempt to query all the servers in parallel. -func (f *StatsFetcher) Fetch(ctx context.Context, servers []*agent.Server) map[string]*structs.ServerStats { +func (f *StatsFetcher) Fetch(ctx context.Context, servers []*metadata.Server) map[string]*structs.ServerStats { type workItem struct { - server *agent.Server + server *metadata.Server replyCh chan *structs.ServerStats } var work []*workItem diff --git a/agent/consul/stats_fetcher_test.go b/agent/consul/stats_fetcher_test.go index 8f9601ebbd..516d08c5ea 100644 --- a/agent/consul/stats_fetcher_test.go +++ b/agent/consul/stats_fetcher_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/metadata" "github.com/hashicorp/consul/testrpc" "github.com/hashicorp/consul/types" ) @@ -34,9 +34,9 @@ func TestStatsFetcher(t *testing.T) { t.Fatalf("bad len: %d", len(members)) } - var servers []*agent.Server + var servers []*metadata.Server for _, member := range members { - ok, server := agent.IsConsulServer(member) + ok, server := metadata.IsConsulServer(member) if !ok { t.Fatalf("bad: %#v", member) } diff --git a/agent/consul/util.go b/agent/consul/util.go index 92c0b66836..c13b6fe701 100644 --- a/agent/consul/util.go +++ b/agent/consul/util.go @@ -7,7 +7,7 @@ import ( "runtime" "strconv" - "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/metadata" "github.com/hashicorp/go-version" "github.com/hashicorp/serf/serf" ) @@ -302,7 +302,7 @@ func runtimeStats() map[string]string { // given Consul version func ServersMeetMinimumVersion(members []serf.Member, minVersion *version.Version) bool { for _, member := range members { - if valid, parts := agent.IsConsulServer(member); valid && parts.Status == serf.StatusAlive { + if valid, parts := metadata.IsConsulServer(member); valid && parts.Status == serf.StatusAlive { if parts.Build.LessThan(minVersion) { return false } diff --git a/agent/consul/agent/server.go b/agent/metadata/server.go similarity index 99% rename from agent/consul/agent/server.go rename to agent/metadata/server.go index 0c51424c63..97beb03158 100644 --- a/agent/consul/agent/server.go +++ b/agent/metadata/server.go @@ -3,7 +3,7 @@ // communicate Consul server information. Gossiped information that ends up // in Server contains the necessary metadata required for servers.Manager to // select which server an RPC request should be routed to. -package agent +package metadata import ( "fmt" diff --git a/agent/consul/agent/server_internal_test.go b/agent/metadata/server_internal_test.go similarity index 98% rename from agent/consul/agent/server_internal_test.go rename to agent/metadata/server_internal_test.go index 3b4f3d7e1f..01c7b41143 100644 --- a/agent/consul/agent/server_internal_test.go +++ b/agent/metadata/server_internal_test.go @@ -1,4 +1,4 @@ -package agent +package metadata import ( "testing" diff --git a/agent/consul/agent/server_test.go b/agent/metadata/server_test.go similarity index 88% rename from agent/consul/agent/server_test.go rename to agent/metadata/server_test.go index f12ca97371..bd67115242 100644 --- a/agent/consul/agent/server_test.go +++ b/agent/metadata/server_test.go @@ -1,10 +1,10 @@ -package agent_test +package metadata_test import ( "net" "testing" - "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/metadata" "github.com/hashicorp/serf/serf" ) @@ -14,19 +14,19 @@ func TestServer_Key_params(t *testing.T) { tests := []struct { name string - sd1 *agent.Server - sd2 *agent.Server + sd1 *metadata.Server + sd2 *metadata.Server equal bool }{ { name: "Addr inequality", - sd1: &agent.Server{ + sd1: &metadata.Server{ Name: "s1", Datacenter: "dc1", Port: 8300, Addr: &net.IPAddr{IP: ipv4a}, }, - sd2: &agent.Server{ + sd2: &metadata.Server{ Name: "s1", Datacenter: "dc1", Port: 8300, @@ -42,7 +42,7 @@ func TestServer_Key_params(t *testing.T) { } // Test Key to make sure it actually works as a key - m := make(map[agent.Key]bool) + m := make(map[metadata.Key]bool) m[*test.sd1.Key()] = true if _, found := m[*test.sd2.Key()]; found != test.equal { t.Errorf("Expected a %v result from map test %s", test.equal, test.name) @@ -68,7 +68,7 @@ func TestIsConsulServer(t *testing.T) { }, Status: serf.StatusLeft, } - ok, parts := agent.IsConsulServer(m) + ok, parts := metadata.IsConsulServer(m) if !ok || parts.Datacenter != "east-aws" || parts.Port != 10000 { t.Fatalf("bad: %v %v", ok, parts) } @@ -101,7 +101,7 @@ func TestIsConsulServer(t *testing.T) { } m.Tags["bootstrap"] = "1" m.Tags["disabled"] = "1" - ok, parts = agent.IsConsulServer(m) + ok, parts = metadata.IsConsulServer(m) if !ok { t.Fatalf("expected a valid consul server") } @@ -117,7 +117,7 @@ func TestIsConsulServer(t *testing.T) { m.Tags["expect"] = "3" delete(m.Tags, "bootstrap") delete(m.Tags, "disabled") - ok, parts = agent.IsConsulServer(m) + ok, parts = metadata.IsConsulServer(m) if !ok || parts.Expect != 3 { t.Fatalf("bad: %v", parts.Expect) } @@ -126,7 +126,7 @@ func TestIsConsulServer(t *testing.T) { } delete(m.Tags, "role") - ok, parts = agent.IsConsulServer(m) + ok, parts = metadata.IsConsulServer(m) if ok { t.Fatalf("unexpected ok server") } @@ -147,7 +147,7 @@ func TestIsConsulServer_Optional(t *testing.T) { // should default to zero. }, } - ok, parts := agent.IsConsulServer(m) + ok, parts := metadata.IsConsulServer(m) if !ok || parts.Datacenter != "east-aws" || parts.Port != 10000 { t.Fatalf("bad: %v %v", ok, parts) } @@ -174,7 +174,7 @@ func TestIsConsulServer_Optional(t *testing.T) { } m.Tags["bootstrap"] = "1" m.Tags["disabled"] = "1" - ok, parts = agent.IsConsulServer(m) + ok, parts = metadata.IsConsulServer(m) if !ok { t.Fatalf("expected a valid consul server") } @@ -190,7 +190,7 @@ func TestIsConsulServer_Optional(t *testing.T) { m.Tags["expect"] = "3" delete(m.Tags, "bootstrap") delete(m.Tags, "disabled") - ok, parts = agent.IsConsulServer(m) + ok, parts = metadata.IsConsulServer(m) if !ok || parts.Expect != 3 { t.Fatalf("bad: %v", parts.Expect) } @@ -199,7 +199,7 @@ func TestIsConsulServer_Optional(t *testing.T) { } delete(m.Tags, "role") - ok, parts = agent.IsConsulServer(m) + ok, parts = metadata.IsConsulServer(m) if ok { t.Fatalf("unexpected ok server") } diff --git a/agent/router/manager.go b/agent/router/manager.go index 497191ba80..19c710e9f7 100644 --- a/agent/router/manager.go +++ b/agent/router/manager.go @@ -1,5 +1,5 @@ // Package servers provides a Manager interface for Manager managed -// agent.Server objects. The servers package manages servers from a Consul +// metadata.Server objects. The servers package manages servers from a Consul // client's perspective (i.e. a list of servers that a client talks with for // RPCs). The servers package does not provide any API guarantees and should // be called only by `hashicorp/consul`. @@ -13,7 +13,7 @@ import ( "sync/atomic" "time" - "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/metadata" "github.com/hashicorp/consul/lib" ) @@ -71,7 +71,7 @@ type Pinger interface { type serverList struct { // servers tracks the locally known servers. List membership is // maintained by Serf. - servers []*agent.Server + servers []*metadata.Server } type Manager struct { @@ -111,7 +111,7 @@ type Manager struct { // begin seeing use after the rebalance timer fires or enough servers fail // organically. If the server is already known, merge the new server // details. -func (m *Manager) AddServer(s *agent.Server) { +func (m *Manager) AddServer(s *metadata.Server) { m.listLock.Lock() defer m.listLock.Unlock() l := m.getServerList() @@ -120,7 +120,7 @@ func (m *Manager) AddServer(s *agent.Server) { found := false for idx, existing := range l.servers { if existing.Name == s.Name { - newServers := make([]*agent.Server, len(l.servers)) + newServers := make([]*metadata.Server, len(l.servers)) copy(newServers, l.servers) // Overwrite the existing server details in order to @@ -135,7 +135,7 @@ func (m *Manager) AddServer(s *agent.Server) { // Add to the list if not known if !found { - newServers := make([]*agent.Server, len(l.servers), len(l.servers)+1) + newServers := make([]*metadata.Server, len(l.servers), len(l.servers)+1) copy(newServers, l.servers) newServers = append(newServers, s) l.servers = newServers @@ -156,13 +156,13 @@ func (m *Manager) AddServer(s *agent.Server) { // less desirable than just returning the next server in the firing line. If // the next server fails, it will fail fast enough and cycleServer will be // called again. -func (l *serverList) cycleServer() (servers []*agent.Server) { +func (l *serverList) cycleServer() (servers []*metadata.Server) { numServers := len(l.servers) if numServers < 2 { return servers // No action required } - newServers := make([]*agent.Server, 0, numServers) + newServers := make([]*metadata.Server, 0, numServers) newServers = append(newServers, l.servers[1:]...) newServers = append(newServers, l.servers[0]) @@ -170,7 +170,7 @@ func (l *serverList) cycleServer() (servers []*agent.Server) { } // removeServerByKey performs an inline removal of the first matching server -func (l *serverList) removeServerByKey(targetKey *agent.Key) { +func (l *serverList) removeServerByKey(targetKey *metadata.Key) { for i, s := range l.servers { if targetKey.Equal(s.Key()) { copy(l.servers[i:], l.servers[i+1:]) @@ -202,7 +202,7 @@ func (m *Manager) IsOffline() bool { // server list. If the server at the front of the list has failed or fails // during an RPC call, it is rotated to the end of the list. If there are no // servers available, return nil. -func (m *Manager) FindServer() *agent.Server { +func (m *Manager) FindServer() *metadata.Server { l := m.getServerList() numServers := len(l.servers) if numServers == 0 { @@ -249,14 +249,14 @@ func New(logger *log.Logger, shutdownCh chan struct{}, clusterInfo ManagerSerfCl atomic.StoreInt32(&m.offline, 1) l := serverList{} - l.servers = make([]*agent.Server, 0) + l.servers = make([]*metadata.Server, 0) m.saveServerList(l) return m } // NotifyFailedServer marks the passed in server as "failed" by rotating it // to the end of the server list. -func (m *Manager) NotifyFailedServer(s *agent.Server) { +func (m *Manager) NotifyFailedServer(s *metadata.Server) { l := m.getServerList() // If the server being failed is not the first server on the list, @@ -290,7 +290,7 @@ func (m *Manager) NumServers() int { return len(l.servers) } -// RebalanceServers shuffles the list of servers on this agent. The server +// RebalanceServers shuffles the list of servers on this metadata. The server // at the front of the list is selected for the next RPC. RPC calls that // fail for a particular server are rotated to the end of the list. This // method reshuffles the list periodically in order to redistribute work @@ -376,14 +376,14 @@ func (m *Manager) reconcileServerList(l *serverList) bool { } type targetServer struct { - server *agent.Server + server *metadata.Server // 'b' == both // 'o' == original // 'n' == new state byte } - mergedList := make(map[agent.Key]*targetServer, len(l.servers)) + mergedList := make(map[metadata.Key]*targetServer, len(l.servers)) for _, s := range l.servers { mergedList[*s.Key()] = &targetServer{server: s, state: 'o'} } @@ -425,7 +425,7 @@ func (m *Manager) reconcileServerList(l *serverList) bool { // RemoveServer takes out an internal write lock and removes a server from // the server list. -func (m *Manager) RemoveServer(s *agent.Server) { +func (m *Manager) RemoveServer(s *metadata.Server) { m.listLock.Lock() defer m.listLock.Unlock() l := m.getServerList() @@ -433,7 +433,7 @@ func (m *Manager) RemoveServer(s *agent.Server) { // Remove the server if known for i := range l.servers { if l.servers[i].Name == s.Name { - newServers := make([]*agent.Server, 0, len(l.servers)-1) + newServers := make([]*metadata.Server, 0, len(l.servers)-1) newServers = append(newServers, l.servers[:i]...) newServers = append(newServers, l.servers[i+1:]...) l.servers = newServers diff --git a/agent/router/manager_internal_test.go b/agent/router/manager_internal_test.go index c11a3c49e8..0425e14f68 100644 --- a/agent/router/manager_internal_test.go +++ b/agent/router/manager_internal_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/metadata" ) var ( @@ -64,14 +64,14 @@ func testManagerFailProb(failPct float64) (m *Manager) { return m } -// func (l *serverList) cycleServer() (servers []*agent.Server) { +// func (l *serverList) cycleServer() (servers []*metadata.Server) { func TestManagerInternal_cycleServer(t *testing.T) { m := testManager() l := m.getServerList() - server0 := &agent.Server{Name: "server1"} - server1 := &agent.Server{Name: "server2"} - server2 := &agent.Server{Name: "server3"} + server0 := &metadata.Server{Name: "server1"} + server1 := &metadata.Server{Name: "server2"} + server2 := &metadata.Server{Name: "server3"} l.servers = append(l.servers, server0, server1, server2) m.saveServerList(l) @@ -167,11 +167,11 @@ func test_reconcileServerList(maxServers int) (bool, error) { const failPct = 0.5 m := testManagerFailProb(failPct) - var failedServers, healthyServers []*agent.Server + var failedServers, healthyServers []*metadata.Server for i := 0; i < maxServers; i++ { nodeName := fmt.Sprintf("s%02d", i) - node := &agent.Server{Name: nodeName} + node := &metadata.Server{Name: nodeName} // Add 66% of servers to Manager if rand.Float64() > 0.33 { m.AddServer(node) @@ -231,7 +231,7 @@ func test_reconcileServerList(maxServers int) (bool, error) { return true, nil } - resultingServerMap := make(map[agent.Key]bool) + resultingServerMap := make(map[metadata.Key]bool) for _, s := range m.getServerList().servers { resultingServerMap[*s.Key()] = true } @@ -303,7 +303,7 @@ func TestManagerInternal_refreshServerRebalanceTimer(t *testing.T) { m := New(logger, shutdownCh, &fauxSerf{numNodes: s.numNodes}, &fauxConnPool{}) for i := 0; i < s.numServers; i++ { nodeName := fmt.Sprintf("s%02d", i) - m.AddServer(&agent.Server{Name: nodeName}) + m.AddServer(&metadata.Server{Name: nodeName}) } d := m.refreshServerRebalanceTimer() @@ -324,7 +324,7 @@ func TestManagerInternal_saveServerList(t *testing.T) { t.Fatalf("Manager.saveServerList failed to load init config") } - newServer := new(agent.Server) + newServer := new(metadata.Server) l.servers = append(l.servers, newServer) m.saveServerList(l) }() @@ -340,7 +340,7 @@ func TestManagerInternal_saveServerList(t *testing.T) { // Verify mutation w/o a save doesn't alter the original func() { - newServer := new(agent.Server) + newServer := new(metadata.Server) l := m.getServerList() l.servers = append(l.servers, newServer) diff --git a/agent/router/manager_test.go b/agent/router/manager_test.go index 35e17d463f..00d63938de 100644 --- a/agent/router/manager_test.go +++ b/agent/router/manager_test.go @@ -9,7 +9,7 @@ import ( "strings" "testing" - "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/metadata" "github.com/hashicorp/consul/agent/router" ) @@ -48,7 +48,7 @@ func testManagerFailProb(failPct float64) (m *router.Manager) { return m } -// func (m *Manager) AddServer(server *agent.Server) { +// func (m *Manager) AddServer(server *metadata.Server) { func TestServers_AddServer(t *testing.T) { m := testManager() var num int @@ -57,7 +57,7 @@ func TestServers_AddServer(t *testing.T) { t.Fatalf("Expected zero servers to start") } - s1 := &agent.Server{Name: "s1"} + s1 := &metadata.Server{Name: "s1"} m.AddServer(s1) num = m.NumServers() if num != 1 { @@ -70,7 +70,7 @@ func TestServers_AddServer(t *testing.T) { t.Fatalf("Expected one server (still)") } - s2 := &agent.Server{Name: "s2"} + s2 := &metadata.Server{Name: "s2"} m.AddServer(s2) num = m.NumServers() if num != 2 { @@ -85,7 +85,7 @@ func TestServers_IsOffline(t *testing.T) { t.Fatalf("bad") } - s1 := &agent.Server{Name: "s1"} + s1 := &metadata.Server{Name: "s1"} m.AddServer(s1) if m.IsOffline() { t.Fatalf("bad") @@ -117,7 +117,7 @@ func TestServers_IsOffline(t *testing.T) { } } -// func (m *Manager) FindServer() (server *agent.Server) { +// func (m *Manager) FindServer() (server *metadata.Server) { func TestServers_FindServer(t *testing.T) { m := testManager() @@ -125,7 +125,7 @@ func TestServers_FindServer(t *testing.T) { t.Fatalf("Expected nil return") } - m.AddServer(&agent.Server{Name: "s1"}) + m.AddServer(&metadata.Server{Name: "s1"}) if m.NumServers() != 1 { t.Fatalf("Expected one server") } @@ -143,7 +143,7 @@ func TestServers_FindServer(t *testing.T) { t.Fatalf("Expected s1 server (still)") } - m.AddServer(&agent.Server{Name: "s2"}) + m.AddServer(&metadata.Server{Name: "s2"}) if m.NumServers() != 2 { t.Fatalf("Expected two servers") } @@ -175,7 +175,7 @@ func TestServers_New(t *testing.T) { } } -// func (m *Manager) NotifyFailedServer(server *agent.Server) { +// func (m *Manager) NotifyFailedServer(server *metadata.Server) { func TestServers_NotifyFailedServer(t *testing.T) { m := testManager() @@ -183,8 +183,8 @@ func TestServers_NotifyFailedServer(t *testing.T) { t.Fatalf("Expected zero servers to start") } - s1 := &agent.Server{Name: "s1"} - s2 := &agent.Server{Name: "s2"} + s1 := &metadata.Server{Name: "s1"} + s2 := &metadata.Server{Name: "s2"} // Try notifying for a server that is not managed by Manager m.NotifyFailedServer(s1) @@ -237,7 +237,7 @@ func TestServers_NumServers(t *testing.T) { t.Fatalf("Expected zero servers to start") } - s := &agent.Server{} + s := &metadata.Server{} m.AddServer(s) num = m.NumServers() if num != 1 { @@ -256,7 +256,7 @@ func TestServers_RebalanceServers(t *testing.T) { // Make a huge list of nodes. for i := 0; i < maxServers; i++ { nodeName := fmt.Sprintf("s%02d", i) - m.AddServer(&agent.Server{Name: nodeName}) + m.AddServer(&metadata.Server{Name: nodeName}) } // Keep track of how many unique shuffles we get. @@ -282,7 +282,7 @@ func TestServers_RebalanceServers(t *testing.T) { } } -// func (m *Manager) RemoveServer(server *agent.Server) { +// func (m *Manager) RemoveServer(server *metadata.Server) { func TestManager_RemoveServer(t *testing.T) { const nodeNameFmt = "s%02d" m := testManager() @@ -293,21 +293,21 @@ func TestManager_RemoveServer(t *testing.T) { // Test removing server before its added nodeName := fmt.Sprintf(nodeNameFmt, 1) - s1 := &agent.Server{Name: nodeName} + s1 := &metadata.Server{Name: nodeName} m.RemoveServer(s1) m.AddServer(s1) nodeName = fmt.Sprintf(nodeNameFmt, 2) - s2 := &agent.Server{Name: nodeName} + s2 := &metadata.Server{Name: nodeName} m.RemoveServer(s2) m.AddServer(s2) const maxServers = 19 - servers := make([]*agent.Server, maxServers) + servers := make([]*metadata.Server, maxServers) // Already added two servers above for i := maxServers; i > 2; i-- { nodeName := fmt.Sprintf(nodeNameFmt, i) - server := &agent.Server{Name: nodeName} + server := &metadata.Server{Name: nodeName} servers = append(servers, server) m.AddServer(server) } @@ -321,7 +321,7 @@ func TestManager_RemoveServer(t *testing.T) { t.Fatalf("Expected %d servers, received %d", maxServers, m.NumServers()) } - findServer := func(server *agent.Server) bool { + findServer := func(server *metadata.Server) bool { for i := m.NumServers(); i > 0; i-- { s := m.FindServer() if s == server { @@ -332,7 +332,7 @@ func TestManager_RemoveServer(t *testing.T) { } expectedNumServers := maxServers - removedServers := make([]*agent.Server, 0, maxServers) + removedServers := make([]*metadata.Server, 0, maxServers) // Remove servers from the front of the list for i := 3; i > 0; i-- { diff --git a/agent/router/router.go b/agent/router/router.go index ac043d9393..3299b781cd 100644 --- a/agent/router/router.go +++ b/agent/router/router.go @@ -6,7 +6,7 @@ import ( "sort" "sync" - "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/metadata" "github.com/hashicorp/consul/agent/structs" "github.com/hashicorp/consul/lib" "github.com/hashicorp/consul/types" @@ -34,7 +34,7 @@ type Router struct { managers map[string][]*Manager // routeFn is a hook to actually do the routing. - routeFn func(datacenter string) (*Manager, *agent.Server, bool) + routeFn func(datacenter string) (*Manager, *metadata.Server, bool) // isShutdown prevents adding new routes to a router after it is shut // down. @@ -140,7 +140,7 @@ func (r *Router) AddArea(areaID types.AreaID, cluster RouterSerfCluster, pinger // initially, and then will quickly detect that they are failed if we // can't reach them. for _, m := range cluster.Members() { - ok, parts := agent.IsConsulServer(m) + ok, parts := metadata.IsConsulServer(m) if !ok { r.logger.Printf("[WARN]: consul: Non-server %q in server-only area %q", m.Name, areaID) @@ -206,7 +206,7 @@ func (r *Router) RemoveArea(areaID types.AreaID) error { } // addServer does the work of AddServer once the write lock is held. -func (r *Router) addServer(area *areaInfo, s *agent.Server) error { +func (r *Router) addServer(area *areaInfo, s *metadata.Server) error { // Make the manager on the fly if this is the first we've seen of it, // and add it to the index. info, ok := area.managers[s.Datacenter] @@ -236,7 +236,7 @@ func (r *Router) addServer(area *areaInfo, s *agent.Server) error { // AddServer should be called whenever a new server joins an area. This is // typically hooked into the Serf event handler area for this area. -func (r *Router) AddServer(areaID types.AreaID, s *agent.Server) error { +func (r *Router) AddServer(areaID types.AreaID, s *metadata.Server) error { r.Lock() defer r.Unlock() @@ -249,7 +249,7 @@ func (r *Router) AddServer(areaID types.AreaID, s *agent.Server) error { // RemoveServer should be called whenever a server is removed from an area. This // is typically hooked into the Serf event handler area for this area. -func (r *Router) RemoveServer(areaID types.AreaID, s *agent.Server) error { +func (r *Router) RemoveServer(areaID types.AreaID, s *metadata.Server) error { r.Lock() defer r.Unlock() @@ -282,7 +282,7 @@ func (r *Router) RemoveServer(areaID types.AreaID, s *agent.Server) error { // is typically hooked into the Serf event handler area for this area. We will // immediately shift traffic away from this server, but it will remain in the // list of servers. -func (r *Router) FailServer(areaID types.AreaID, s *agent.Server) error { +func (r *Router) FailServer(areaID types.AreaID, s *metadata.Server) error { r.RLock() defer r.RUnlock() @@ -309,13 +309,13 @@ func (r *Router) FailServer(areaID types.AreaID, s *agent.Server) error { // connection attempt. If any problem occurs with the given server, the caller // should feed that back to the manager associated with the server, which is // also returned, by calling NofifyFailedServer(). -func (r *Router) FindRoute(datacenter string) (*Manager, *agent.Server, bool) { +func (r *Router) FindRoute(datacenter string) (*Manager, *metadata.Server, bool) { return r.routeFn(datacenter) } // findDirectRoute looks for a route to the given datacenter if it's directly // adjacent to the server. -func (r *Router) findDirectRoute(datacenter string) (*Manager, *agent.Server, bool) { +func (r *Router) findDirectRoute(datacenter string) (*Manager, *metadata.Server, bool) { r.RLock() defer r.RUnlock() @@ -399,7 +399,7 @@ func (r *Router) GetDatacentersByDistance() ([]string, error) { } for _, m := range info.cluster.Members() { - ok, parts := agent.IsConsulServer(m) + ok, parts := metadata.IsConsulServer(m) if !ok { r.logger.Printf("[WARN]: consul: Non-server %q in server-only area %q", m.Name, areaID) @@ -460,7 +460,7 @@ func (r *Router) GetDatacenterMaps() ([]structs.DatacenterMap, error) { for areaID, info := range r.areas { index := make(map[string]structs.Coordinates) for _, m := range info.cluster.Members() { - ok, parts := agent.IsConsulServer(m) + ok, parts := metadata.IsConsulServer(m) if !ok { r.logger.Printf("[WARN]: consul: Non-server %q in server-only area %q", m.Name, areaID) diff --git a/agent/router/serf_adapter.go b/agent/router/serf_adapter.go index 768834c0da..12941b140a 100644 --- a/agent/router/serf_adapter.go +++ b/agent/router/serf_adapter.go @@ -3,13 +3,13 @@ package router import ( "log" - "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/metadata" "github.com/hashicorp/consul/types" "github.com/hashicorp/serf/serf" ) // routerFn selects one of the router operations to map to incoming Serf events. -type routerFn func(types.AreaID, *agent.Server) error +type routerFn func(types.AreaID, *metadata.Server) error // handleMemberEvents attempts to apply the given Serf member event to the given // router function. @@ -21,7 +21,7 @@ func handleMemberEvent(logger *log.Logger, fn routerFn, areaID types.AreaID, e s } for _, m := range me.Members { - ok, parts := agent.IsConsulServer(m) + ok, parts := metadata.IsConsulServer(m) if !ok { logger.Printf("[WARN]: consul: Non-server %q in server-only area %q", m.Name, areaID) diff --git a/agent/router/serf_flooder.go b/agent/router/serf_flooder.go index f13e48fcf3..fee912dd65 100644 --- a/agent/router/serf_flooder.go +++ b/agent/router/serf_flooder.go @@ -6,13 +6,13 @@ import ( "net" "strings" - "github.com/hashicorp/consul/agent/consul/agent" + "github.com/hashicorp/consul/agent/metadata" "github.com/hashicorp/serf/serf" ) // FloodPortFn gets the port to use for a given server when flood-joining. This // will return false if it doesn't have one. -type FloodPortFn func(*agent.Server) (int, bool) +type FloodPortFn func(*metadata.Server) (int, bool) // FloodJoins attempts to make sure all Consul servers in the local Serf // instance are joined in the global Serf instance. It assumes names in the @@ -27,9 +27,9 @@ func FloodJoins(logger *log.Logger, portFn FloodPortFn, // Index the global side so we can do one pass through the local side // with cheap lookups. - index := make(map[string]*agent.Server) + index := make(map[string]*metadata.Server) for _, m := range globalSerf.Members() { - ok, server := agent.IsConsulServer(m) + ok, server := metadata.IsConsulServer(m) if !ok { continue } @@ -48,7 +48,7 @@ func FloodJoins(logger *log.Logger, portFn FloodPortFn, continue } - ok, server := agent.IsConsulServer(m) + ok, server := metadata.IsConsulServer(m) if !ok { continue }