I'm trying to run linkerd with some custom namer plug-in but failing on startup. I've got the source code of io.l5d.fs and cut off all the business logic to get some minimalistic example with hardcoded addresses.
Initializer:
package com.consg
import io.buoyant.namer.NamerInitializer
class MyInitializer extends NamerInitializer {
val configClass = classOf[MyConfig]
override def configId = "com.consg.MyConfig"
}
object MyInitializer extends MyInitializer
Config:
package com.consg
import com.fasterxml.jackson.annotation.JsonIgnore
import com.twitter.finagle.{Path, Stack}
import io.buoyant.config.types.Directory
import io.buoyant.namer.NamerConfig
case class MyConfig(rootDir: Directory) extends NamerConfig {
@JsonIgnore
override def defaultPrefix: Path = Path.read("/my.namer")
@JsonIgnore
def newNamer(params: Stack.Params) = {
println("params: " + params)
new MyNamer(rootDir.path, prefix)
}
}
Namer:
package com.consg
import java.nio.file.{Path => NioPath}
import com.twitter.finagle._
import com.twitter.util._
import io.buoyant.namer.EnumeratingNamer
class MyNamer(rootDir: NioPath, prefix: Path) extends EnumeratingNamer {
def lookup(path: Path): Activity[NameTree[Name]] = {
println("lookup path: " + path)
val address1 = Address("127.0.0.1", 7777)
val addr = Addr.Bound(Set(address1), Addr.Metadata.empty)
val varr = Var.apply(addr)
Activity.value(NameTree.Leaf(Name.Bound(varr, path, path)))
}
override def getAllNames: Activity[Set[Path]] = {
println("getAllNames!")
Activity.value(Set.apply(Path.read("animal")))
}
}
build.sbt
name := "plug"
version := "1"
scalaVersion := "2.12.1"
libraryDependencies += "io.buoyant" % "linkerd-core_2.12" % "1.3.2" % "provided"
Also I exposed the "com.consg.MyInitializer" service under META-INF/services/io.buoyant.namer.NamerInitializer
Then I build the plugin jar & placed it under plugins (linkerd-1.3.1/plugins)
Now I'm trying to run linkerd with config:
namers:
- kind: com.consg.MyConfig
rootDir: disco
routers:
- protocol: http
dtab: /svc => /#/my.namer;
servers:
- port: 8080
And as a result I've got:
com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve type id 'com.consg.MyConfig' into a subtype of [simple type, class io.buoyant.namer.NamerConfig]: known type ids = [NamerConfig, io.l5d.consul, io.l5d.curator, io.l5d.dnssrv, io.l5d.fs, io.l5d.k8s, io.l5d.k8s.external, io.l5d.k8s.ns, io.l5d.marathon, io.l5d.rewrite, io.l5d.serversets, io.l5d.zkLeader]
So it looks like the plugin not loaded at all. Need some help.
Looks like my problem was undefined $L5D_HOME environment variable. After I've set it the plug-in was enabled.