This repository has been archived by the owner on Sep 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KEST-272: proper config inheritance; log queue/alias config on reload
RB_ID=87497
- Loading branch information
Stephan Zuercher
committed
Sep 21, 2012
1 parent
ea9d4da
commit bf4ac4d
Showing
12 changed files
with
590 additions
and
177 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
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,44 @@ | ||
/* | ||
* Copyright 2009 Twitter, Inc. | ||
* Copyright 2009 Robey Pointer <robeypointer@gmail.com> | ||
* | ||
* 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 net.lag.kestrel | ||
package config | ||
|
||
case class AliasConfig( | ||
destinationQueues: List[String] | ||
) { | ||
override def toString() = { | ||
("destinationQueues=[%s]").format(destinationQueues.mkString(", ")) | ||
} | ||
} | ||
|
||
class AliasBuilder { | ||
/** | ||
* Name of the alias being configured. | ||
*/ | ||
var name: String = null | ||
|
||
/** | ||
* List of queues which receive items added to this alias. | ||
*/ | ||
var destinationQueues: List[String] = Nil | ||
|
||
def apply() = { | ||
AliasConfig(destinationQueues) | ||
} | ||
} | ||
|
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,59 @@ | ||
/* | ||
* Copyright 2012 Twitter, 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 net.lag.kestrel | ||
package config | ||
|
||
/** | ||
* ConfigValue represents a value that may either be a default or a | ||
* configuration-specified value. A ConfigValue may be resolved against | ||
* another value. | ||
*/ | ||
sealed abstract class ConfigValue[A](x: A) { | ||
def isSpecified: Boolean | ||
def get = x | ||
def resolve(default: Option[A]): A = { | ||
default match { | ||
case Some(_) if isSpecified => get | ||
case Some(v) => v | ||
case None => get | ||
} | ||
} | ||
} | ||
|
||
/* | ||
* SpecifiedValue is a ConfigValue specified in a configuration. | ||
*/ | ||
case class SpecifiedValue[A](x: A) extends ConfigValue[A](x) { | ||
def isSpecified = true | ||
} | ||
|
||
/* | ||
* Default is a ConfigValue specified as a default. | ||
*/ | ||
case class Default[A] private[config] (x: A) extends ConfigValue[A](x) { | ||
def isSpecified = false | ||
} | ||
|
||
/** | ||
* The ConfigValue companion object provides implicit methods to convert | ||
* bare objects into SpecifiedValue instances. | ||
*/ | ||
object ConfigValue { | ||
implicit def wrap[A](x: A): ConfigValue[A] = SpecifiedValue(x) | ||
implicit def wrapToOption[A](x: A): ConfigValue[Option[A]] = SpecifiedValue(Some(x)) | ||
implicit def wrapNone[A](x: None.type): ConfigValue[Option[A]] = SpecifiedValue(None) | ||
} |
Oops, something went wrong.