forked from istio/old_mixer_repo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce adapter composition model.
The type 'Adapter' is a singleton per adapter binary linked into the mixer. The type 'Instance' captures individual instantiations of a single adapter. Updated the fact mapper code to follow the new model.
- stable-ffaa25e
- stable-ff22555
- stable-fe1bc4d
- stable-fc7fa98
- stable-fbe9a24
- stable-f88245b
- stable-f1bf3ca
- stable-efb0663
- stable-ec39700
- stable-ea388cd
- stable-ea96b72
- stable-e34d874
- stable-e6ec74c
- stable-df73d50
- stable-dae065b
- stable-daa9124
- stable-d32b987
- stable-d8c4de1
- stable-d6fd5ef
- stable-d3b7861
- stable-cf32516
- stable-ccbc4ea
- stable-cca2d6f
- stable-cbdf7f3
- stable-ca58f01
- stable-c6110a5
- stable-c570a67
- stable-c74f24a
- stable-c43e470
- stable-c30e285
- stable-c6fee1f
- stable-bc22811
- stable-bab2452
- stable-b52935b
- stable-b875f9f
- stable-b83d5b2
- stable-b5aea97
- stable-b3a7749
- stable-b0be867
- stable-afdf173
- stable-af36f89
- stable-adeef8f
- stable-a15700f
- stable-a9e5994
- stable-a00d4c5
- stable-7238802
- stable-4133437
- stable-3284323
- stable-2903300
- stable-862182a
- stable-0640010
- stable-103851c
- stable-82070e1
- stable-79941d7
- stable-58032e2
- stable-57175ed
- stable-45918c7
- stable-7975cab
- stable-6391fb4
- stable-4968c47
- stable-2293b3a
- stable-1870ac8
- stable-01545a2
- stable-986bf7a
- stable-794d546
- stable-791a3c5
- stable-0754fe4
- stable-671b8f9
- stable-570ffe7
- stable-565c987
- stable-265c0d3
- stable-246ad16
- stable-233d6ba
- stable-0120f0b
- stable-089b9a1
- stable-87d0816
- stable-76e2e67
- stable-75ecdd0
- stable-073c270
- stable-66a7f1c
- stable-61f4da0
- stable-55b8563
- stable-53e2471
- stable-49bde5c
- stable-048b172
- stable-44bc520
- stable-43b7626
- stable-30a4d01
- stable-17e1dc8
- stable-16ff568
- stable-09f95a0
- stable-9da7b34
- stable-8f5bdba
- stable-8ed8a88
- stable-08dfccd
- stable-8b0f6d7
- stable-7b726aa
- stable-6fa8ac8
- stable-6ec8774
- stable-06e8961
- stable-6bfa390
- stable-6b9581e
- stable-5bae502
- stable-4eabc03
- stable-4c5fba7
- stable-4b27bdc
- stable-4b9d38b
- stable-3fe979a
- stable-3d2abc8
- stable-3c19fd9
- stable-2e6870d
- stable-2b2e5c4
- stable-1f47133
- stable-1eb238c
- stable-1bb187e
- stable-0f45031
- stable-0d77098
- stable-0b3be67
- 0.2.1
- 0.2.0
- 0.1.6
- 0.1.5
- 0.1.4
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1.0
Martin Taillefer
committed
Nov 27, 2016
1 parent
b613811
commit df6a80c
Showing
11 changed files
with
228 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2016 Google Inc. | ||
// | ||
// 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 | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// 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. | ||
|
||
package adapters | ||
|
||
// AdapterConfig is used to configure an adapter. | ||
type AdapterConfig interface{} | ||
|
||
// Adapter represents the handle that the mixer has on an individual adapter. The mixer holds on | ||
// to one of these per logical adapter, which the mixer uses to control the lifecycle of both | ||
// adapters and adapter instances. | ||
type Adapter interface { | ||
// Name returns the official name of this adapter for use in diagnostics and in config | ||
Name() string | ||
|
||
// Description returns a user-friendly description of this adapter. | ||
Description() string | ||
|
||
// DefaultConfig returns a default configuration struct for this adapter. | ||
// This will be used by the configuration system to establish the shape of a block | ||
// of configuration state passed to the Activate function. | ||
DefaultConfig() AdapterConfig | ||
|
||
// Activate the adapter with the given configuration. Once an adapter is active, | ||
// the mixer can start calling the CreateInstance function to instantiate the adapter | ||
Activate(config AdapterConfig) error | ||
|
||
// Deactivate the adapter, allowing it to clean up any resources it might be holding. | ||
// Once this function is called, the mixer may no longer call the CreateInstance function. | ||
Deactivate() | ||
|
||
// DefaultInstanceConfig returns a default configuration struct for instances | ||
// of this adapter. This will be used by the configuration system to establish | ||
// the shape of a block of configuration state passed to the Activate function | ||
DefaultInstanceConfig() InstanceConfig | ||
|
||
// CreateInstance creates a single instance of the adapter based on the supplied configuration. | ||
CreateInstance(config InstanceConfig) (Instance, error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2016 Google Inc. | ||
// | ||
// 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 | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// 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. | ||
|
||
package factMapper | ||
|
||
import ( | ||
"github.com/istio/mixer/adapters" | ||
) | ||
|
||
// AdapterConfig is used to configure a fact mapper adapter. | ||
type AdapterConfig struct{} | ||
|
||
type adapter struct{} | ||
|
||
// NewFactMapperAdapter returns an Adapter | ||
func NewFactMapperAdapter() adapters.Adapter { | ||
return adapter{} | ||
} | ||
|
||
func (a adapter) Name() string { | ||
return "FactMapper" | ||
} | ||
|
||
func (a adapter) Description() string { | ||
return "Performs config-driven mapping of facts to labels" | ||
} | ||
|
||
func (a adapter) DefaultConfig() adapters.AdapterConfig { | ||
return AdapterConfig{} | ||
} | ||
|
||
func (a adapter) Activate(config adapters.AdapterConfig) error { | ||
_ = config.(AdapterConfig) | ||
return nil | ||
} | ||
|
||
func (a adapter) Deactivate() { | ||
} | ||
|
||
func (a adapter) DefaultInstanceConfig() adapters.InstanceConfig { | ||
return InstanceConfig{} | ||
} | ||
|
||
func (a adapter) CreateInstance(config adapters.InstanceConfig) (adapters.Instance, error) { | ||
c := config.(InstanceConfig) | ||
return newInstance(&c) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2016 Google Inc. | ||
// | ||
// 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 | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// 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. | ||
|
||
package adapters | ||
|
||
// InstanceConfig is used to configure an individual instance of an adapter. | ||
type InstanceConfig interface{} | ||
|
||
// Instance defines lifecycle functions for individual adapter instances. | ||
type Instance interface { | ||
// Delete is called by the mixer to indicate it is done with a particular adapter instance. | ||
Delete() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.