我是 golang 泛型的新手,并且有以下设置。
ReportContainerImpl我使用了一个类型参数, [T Reportable]其Reportable定义如下
type Reportable interface {
ExportDataPointReport | ImportDataPointReport | MissingDataPointReport | SensorThresoldReport
}
Run Code Online (Sandbox Code Playgroud)
类型约束中的每个类型都是要嵌入到容器中的结构。
type ReportContainerImpl[T Reportable] struct {
LocationID string `json:"lid"`
Provider string `json:"pn"`
ReportType ReportType `json:"m"`
Body T `json:"body"`
}
Run Code Online (Sandbox Code Playgroud)
我使用鉴别器ReportType来确定何时的具体类型Unmarshal。
type ReportType string
const (
ReportTypeExportDataPointReport ReportType = "ExportDataPointReport"
ReportTypeImportDataPointReport ReportType = "ImportDataPointReport"
ReportTypeMissingDataPointReport ReportType = "MissingDataPointReport"
ReportTypeSensorThresoldReport ReportType = "SensorThresoldReport"
)
Run Code Online (Sandbox Code Playgroud)
由于go不支持struct的类型断言(仅支持接口),因此无法在 when …
我正在尝试将Felix嵌入嵌入式Tomcat中.一切正常.但是,当关闭Felix框架(已部署SCR,cm,事件管理和元类型服务)时,它将为我提供框架关闭事件.但是线程在ResolveImpl执行器中仍然存在.
所以我有一堆"FelixResolver-"线程仍悬空.我不能强制关闭线程,因为它们属于执行程序.
关机顺序:
framework.stop();
final FrameworkEvent fe = framework.waitForStop(wait);
Run Code Online (Sandbox Code Playgroud)
我明白了
fe.getType() == FrameworkEvent.STOPPED.
Run Code Online (Sandbox Code Playgroud)
Felix Framework是'org.apache.felix.framework-5.6.1.jar'
我正在使用以下felix包:
我手动安装并启动捆绑包.我没有停止捆绑,而是使用上面的方法停止框架捆绑.
安装顺序(安装后的启动顺序相同):
我究竟做错了什么?
干杯,马里奥
编辑1:
我已升级到felix框架5.6.2,但问题仍然存在.
(使用Newtonsoft JSON.NET)
嗨,我在反序列化事件列表时遇到了一个问题,其中Event是基本类型,例如ResourceEvent是子类。如果我只是进行序列化然后反序列化,一切正常,并且列表包含ResourceEvents-但是,我将使用EF7的事件存储在postgres的jsonb列中。
当我从postgres获取JSON有效负载时,它已经对属性进行了重新排序(但JSON合法)。当我尝试使用Newtonsoft JSON.net进行反序列化时,它只给我一个包含基本类型Event而不是子类ResourceEvent的列表。
我添加了两个高度剥离的示例,区别在于“ Type”属性在不同位置。在类中还对其他属性的顺序进行了排序。我根本没有在类上的注释。
此有效载荷成功地反硝化:
json
{
"$type": "System.Collections.Generic.List`1[[Event, Tests]], mscorlib",
"$values": [
{
"$type": "ResourceConfigurationEvent, Tests",
/* Properties */
"Resources": {
/* Properties */
},
"Type": 1
}
]
}
Run Code Online (Sandbox Code Playgroud)
该有效负载未能成功反序列化:
json
{
"$type": "System.Collections.Generic.List`1[[Event, Tests]], mscorlib",
"$values": [
{
"Type": 1,
"$type": "ResourceConfigurationEvent, Tests",
/* Properties */
"Resources": {
/* Properties */
},
}
]
}
Run Code Online (Sandbox Code Playgroud) 我想知道是否可以在实体框架 7 中进行 postgres 表继承 - 而不是添加列,而是使用基表和继承基表的表来执行“真正的”postgres?
如果是这样,我该如何配置?
干杯,马里奥
postgresql ×2
apache-felix ×1
c# ×1
generics ×1
go ×1
json ×1
json.net ×1
jsonb ×1
marshalling ×1
npgsql ×1
osgi ×1
resolver ×1
threadpool ×1