-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch Metadata to mapbinder and expose module to wrap install (#3231)
* Switch Metadata to mapbinder and expose module to wrap install * Add MetadataModule to wrap installation * apiDump * Fix API breaks * Fix broken API
- Loading branch information
Showing
15 changed files
with
110 additions
and
44 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
8 changes: 5 additions & 3 deletions
8
misk-admin/src/main/kotlin/misk/web/metadata/config/ConfigMetadata.kt
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
9 changes: 6 additions & 3 deletions
9
misk-admin/src/main/kotlin/misk/web/metadata/database/DatabaseHibernateMetadata.kt
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 |
---|---|---|
@@ -1,14 +1,17 @@ | ||
package misk.web.metadata.database | ||
|
||
import com.google.inject.Provider | ||
import jakarta.inject.Inject | ||
import misk.web.metadata.Metadata | ||
import misk.web.metadata.MetadataProvider | ||
|
||
data class DatabaseHibernateMetadata( | ||
val hibernate: List<DatabaseQueryMetadata> | ||
) : Metadata(id = "database-hibernate", metadata = hibernate) | ||
) : Metadata(metadata = hibernate) | ||
|
||
class DatabaseHibernateMetadataProvider : Provider<DatabaseHibernateMetadata> { | ||
class DatabaseHibernateMetadataProvider : MetadataProvider<DatabaseHibernateMetadata> { | ||
@Inject lateinit var metadata: List<DatabaseQueryMetadata> | ||
|
||
override val id: String = "database-hibernate" | ||
|
||
override fun get() = DatabaseHibernateMetadata(hibernate = metadata) | ||
} |
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 |
---|---|---|
@@ -1,8 +1,6 @@ | ||
package misk.web.metadata | ||
|
||
open class Metadata( | ||
/** Unique identifier for the type of metadata. Ie. "web-actions" or "config". */ | ||
val id: String, | ||
/** Metadata object, should be a data class for easy built-in serialization to JSON. */ | ||
val metadata: Any, | ||
) |
11 changes: 11 additions & 0 deletions
11
misk-config/src/main/kotlin/misk/web/metadata/MetadataModule.kt
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,11 @@ | ||
package misk.web.metadata | ||
|
||
import misk.inject.KAbstractModule | ||
|
||
/** Installs a new Metadata type with associated provider to expose in [AllMetadataAction]. */ | ||
class MetadataModule<T: Metadata>(private val provider: MetadataProvider<T>): KAbstractModule() { | ||
override fun configure() { | ||
val binder = newMapBinder<String, Metadata>() | ||
binder.addBinding(provider.id).toProvider(provider) | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
misk-config/src/main/kotlin/misk/web/metadata/MetadataProvider.kt
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,8 @@ | ||
package misk.web.metadata | ||
|
||
import com.google.inject.Provider | ||
|
||
interface MetadataProvider<T: Metadata> : Provider<T> { | ||
/** Unique identifier for the type of metadata. Ie. "web-actions" or "config". */ | ||
val id: String | ||
} |
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