2017-01-20 16:59:14 +01:00
|
|
|
/*
|
|
|
|
*
|
2017-08-11 19:19:46 +02:00
|
|
|
* Copyright 2014 gRPC authors.
|
2017-01-20 16:59:14 +01:00
|
|
|
*
|
2017-08-11 19:19:46 +02:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2017-01-20 16:59:14 +01:00
|
|
|
*
|
2017-08-11 19:19:46 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2017-01-20 16:59:14 +01:00
|
|
|
*
|
2017-08-11 19:19:46 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2017-01-20 16:59:14 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Package naming defines the naming API and related data structures for gRPC.
|
2018-09-24 18:30:39 +02:00
|
|
|
//
|
command: Unmanaged providers
This adds supports for "unmanaged" providers, or providers with process
lifecycles not controlled by Terraform. These providers are assumed to
be started before Terraform is launched, and are assumed to shut
themselves down after Terraform has finished running.
To do this, we must update the go-plugin dependency to v1.3.0, which
added support for the "test mode" plugin serving that powers all this.
As a side-effect of not needing to manage the process lifecycle anymore,
Terraform also no longer needs to worry about the provider's binary, as
it won't be used for anything anymore. Because of this, we can disable
the init behavior that concerns itself with downloading that provider's
binary, checking its version, and otherwise managing the binary.
This is all managed on a per-provider basis, so managed providers that
Terraform downloads, starts, and stops can be used in the same commands
as unmanaged providers. The TF_REATTACH_PROVIDERS environment variable
is added, and is a JSON encoding of the provider's address to the
information we need to connect to it.
This change enables two benefits: first, delve and other debuggers can
now be attached to provider server processes, and Terraform can connect.
This allows for attaching debuggers to provider processes, which before
was difficult to impossible. Second, it allows the SDK test framework to
host the provider in the same process as the test driver, while running
a production Terraform binary against the provider. This allows for Go's
built-in race detector and test coverage tooling to work as expected in
provider tests.
Unmanaged providers are expected to work in the exact same way as
managed providers, with one caveat: Terraform kills provider processes
and restarts them once per graph walk, meaning multiple times during
most Terraform CLI commands. As unmanaged providers can't be killed by
Terraform, and have no visibility into graph walks, unmanaged providers
are likely to have differences in how their global mutable state behaves
when compared to managed providers. Namely, unmanaged providers are
likely to retain global state when managed providers would have reset
it. Developers relying on global state should be aware of this.
2020-05-27 02:48:57 +02:00
|
|
|
// This package is deprecated: please use package resolver instead.
|
2017-01-20 16:59:14 +01:00
|
|
|
package naming
|
|
|
|
|
|
|
|
// Operation defines the corresponding operations for a name resolution change.
|
2018-09-24 18:30:39 +02:00
|
|
|
//
|
|
|
|
// Deprecated: please use package resolver.
|
2017-01-20 16:59:14 +01:00
|
|
|
type Operation uint8
|
|
|
|
|
|
|
|
const (
|
|
|
|
// Add indicates a new address is added.
|
|
|
|
Add Operation = iota
|
2018-09-24 18:30:39 +02:00
|
|
|
// Delete indicates an existing address is deleted.
|
2017-01-20 16:59:14 +01:00
|
|
|
Delete
|
|
|
|
)
|
|
|
|
|
|
|
|
// Update defines a name resolution update. Notice that it is not valid having both
|
|
|
|
// empty string Addr and nil Metadata in an Update.
|
2018-09-24 18:30:39 +02:00
|
|
|
//
|
|
|
|
// Deprecated: please use package resolver.
|
2017-01-20 16:59:14 +01:00
|
|
|
type Update struct {
|
|
|
|
// Op indicates the operation of the update.
|
|
|
|
Op Operation
|
|
|
|
// Addr is the updated address. It is empty string if there is no address update.
|
|
|
|
Addr string
|
|
|
|
// Metadata is the updated metadata. It is nil if there is no metadata update.
|
|
|
|
// Metadata is not required for a custom naming implementation.
|
|
|
|
Metadata interface{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Resolver creates a Watcher for a target to track its resolution changes.
|
2018-09-24 18:30:39 +02:00
|
|
|
//
|
|
|
|
// Deprecated: please use package resolver.
|
2017-01-20 16:59:14 +01:00
|
|
|
type Resolver interface {
|
|
|
|
// Resolve creates a Watcher for target.
|
|
|
|
Resolve(target string) (Watcher, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Watcher watches for the updates on the specified target.
|
2018-09-24 18:30:39 +02:00
|
|
|
//
|
|
|
|
// Deprecated: please use package resolver.
|
2017-01-20 16:59:14 +01:00
|
|
|
type Watcher interface {
|
|
|
|
// Next blocks until an update or error happens. It may return one or more
|
|
|
|
// updates. The first call should get the full set of the results. It should
|
|
|
|
// return an error if and only if Watcher cannot recover.
|
|
|
|
Next() ([]*Update, error)
|
|
|
|
// Close closes the Watcher.
|
|
|
|
Close()
|
|
|
|
}
|