我们正在使用
TestBed.overrideComponent(CoolComponent, {
set: {
template: '<div id="fake-component">i am the fake component</div>',
selector: 'our-cool-component',
inputs: [ 'model' ]
}
})
Run Code Online (Sandbox Code Playgroud)
覆盖组件.
该组件有一个ViewChild,我们在ngOnInit方法中配置它
@Component({
selector: 'our-cool-component',
templateUrl: 'cool.component.html'
})
export class CoolComponent implements OnInit, OnDestroy {
@Input() model: SomeModel
@ViewChild(CoolChildComponent) coolChildComponent;
ngOnInit() {
this.coolChildComponent.doStuff();
}
}
Run Code Online (Sandbox Code Playgroud)
在CoolComponent又住在一个Wrapper组件.
当我们调用fixture.detectChanges()上的Wrapper夹具,这个试图构建CoolComponent,但是当它调用doStuff立即死亡(),因为CoolChildComponent是不确定的.
有没有办法找到CoolComponent它的存根CoolChildComponent?看起来我们不能把它搞定,Wrapper因为它只是通过模板引用,而不是作为组件的属性引用.
integration-testing specifications testbed typescript angular
根据文档,我已经尝试按如下方式更新副本数量
curl -XPUT 'localhost:9200/_settings' -d '
{ "index" : { "number_of_replicas" : 4 } }'
Run Code Online (Sandbox Code Playgroud)
这会正确更改现有节点的副本计数.但是,当logstash在第二天创建新索引时,number_of_replicas将设置为旧值.
有没有办法永久更改此设置的默认值而不更新elasticsearch.yml群集中的所有文件并重新启动服务?
FWIW我也试过了
curl -XPUT 'localhost:9200/logstash-*/_settings' -d '
{ "index" : { "number_of_replicas" : 4 } }'
Run Code Online (Sandbox Code Playgroud)
无济于事.
我有一个我最近使用的数据库的本地实例DbContext.Database.Create(),因此该__MigrationHistory表存在一个InitalCreate与当前代码匹配的条目.
但是,迁移文件夹中存在一些基于代码的迁移.这些将在我们的开发和登台环境中运行,以使这些数据库与代码保持一致.但是,我不需要在本地应用它们,因为我使用当前代码创建了数据库.
我现在需要对模型进行更改并创建相应的迁移.但是当我跑步时Add-Migration TestMigration,我得到以下错误
Unable to generate an explicit migration because the following explicit
migrations are pending:
[201203271113060_AddTableX,
201203290856574_AlterColumnY]
Apply the pending explicit migrations before attempting to generate
a new explicit migration.
Run Code Online (Sandbox Code Playgroud)
在这种情况下我该怎么办?我不能将Add-Migration工具指向另一个环境,因为它不能保证版本与我本地的版本匹配.我想要一个只与我所做的更改匹配的迁移.
看来我有几个选择,但没有一个是理想的:
有没有人有任何关于如何管理这个的建议?
当确定应该将包中的哪些dll添加为程序集引用时,NuGet会排除任何结束".Resources.dll"的内容.这旨在排除本地化的附属程序集,但是如果您有一个名为MyCompany.Resources.dll的DLL,则意味着添加引用很棘手.
这有什么好的解决方法吗?
给定一些具有无法解析的占位符的应用程序配置,如下所示 application.yml
my:
thing: ${missing-placeholder}/whatever
Run Code Online (Sandbox Code Playgroud)
使用@Value批注时,将验证配置文件中的占位符,因此在这种情况下:
package com.test;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class PropValues {
@Value("${my.thing}") String thing;
public String getThing() { return thing; }
}
Run Code Online (Sandbox Code Playgroud)
我得到一个IllegalArgumentException: Could not resolve placeholder 'missing-placeholder' in value "${missing-placeholder}/whatever"。这是因为该值是直接由设置的AbstractBeanFactory.resolveEmbeddedValue,没有任何东西可以捕获由抛出的异常PropertyPlaceholderHelper.parseStringValue
但是,在寻找@ConfigurationProperties样式时,我注意到缺少此验证,例如在这种情况下:
package com.test;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;
@ConfigurationProperties(prefix = "my")
public class Props {
private String thing;
public String getThing() { return thing; }
public void setThing(String thing) { this.thing = thing; }
} …Run Code Online (Sandbox Code Playgroud) validation configuration spring spring-boot spring-boot-configuration
我有以下 JMESPath 查询
query="Reservations[].Instances[].{ \
InstanceId: InstanceId, \
RootDeviceVolumeId: BlockDeviceMappings[?DeviceName==\`/dev/sda1\`] \
| [].Ebs.VolumeId | [0], \
RootDeviceName: RootDeviceName \
}"
aws ec2 describe-instances --query $query
Run Code Online (Sandbox Code Playgroud)
给出这样的输出
+------------+------------------+----------------------+
| InstanceId | RootDeviceName | RootDeviceVolumeId |
+------------+------------------+----------------------+
| i-12345678| /dev/sda1 | vol-abcdef12 |
| i-98765432| /dev/sda1 | vol-ef123456 |
| i-23456789| /dev/sda1 | vol-fedcba09 |
| i-aabbccdd| /dev/xvda | None |
+------------+------------------+----------------------+
Run Code Online (Sandbox Code Playgroud)
我想找到一种RootDeviceName从过滤器表达式中引用的方法BlockDeviceMappings,而不是对/dev/sda1设备名称进行硬编码,因为有时是/dev/xvda这样。但是,我找不到在过滤器表达式中引用父元素的方法。
另一种选择是将 and 映射RootDeviceName到InstanceId所有设备的投影上,然后将其通过管道传输到过滤器表达式,但语法似乎也不支持在投影中包含父元素。
我是否遗漏了某些内容,或者这只是 JMESPath 语法的限制?
我有一个Windows服务,使用Entity Framework 5从数据库中的队列中读取电子邮件,然后使用System.Net.Mail.SmtpClient将它们发送到SMTP服务器
这是我第一次尝试编写F#应用程序,我来自C#背景.如何更好地改进功能和/或充分利用F#的功能?你能解释一下这些改变的优势是什么吗?
worker由服务主机构建,在服务启动时调用其工作函数,在服务停止时将ContinueWorking设置为false.
namespace EmailService
open log4net
open System
open System.Linq
open System.Net.Mail
open EmailService.Context
type Worker(contextFactory: EmailContextFactory, mailClient: ISmtpClient, logger: ILog) =
let MapToMessage(email : Email) =
let message = new MailMessage()
message.Sender <- new MailAddress(email.From)
message.From <- new MailAddress(email.From)
message.Subject <- email.Subject
message.Body <- email.Body
message.IsBodyHtml <- email.IsBodyHtml
message.To.Add(email.To)
(email, message)
member val ContinueWorking = true with get, set
member this.Work() =
logger.Info "Starting work"
let mutable unsentEmails = Array.empty<Email>
while this.ContinueWorking do
use context = …Run Code Online (Sandbox Code Playgroud) 使用超时和CancellationToken调用Async.RunSynchronously时,似乎忽略超时值.我可以通过在CancellationToken上调用CancelAfter来解决这个问题,但理想情况下我希望能够区分工作流中出现的异常,TimeOutExceptions和OperationCanceledExceptions.
我相信下面的示例代码演示了这一点.
open System
open System.Threading
let work =
async {
let endTime = DateTime.UtcNow.AddMilliseconds(100.0)
while DateTime.UtcNow < endTime do
do! Async.Sleep(10)
Console.WriteLine "working..."
raise ( Exception "worked for more than 100 millis" )
}
[<EntryPoint>]
let main argv =
try
Async.RunSynchronously(work, 50)
with
| e -> Console.WriteLine (e.GetType().Name + ": " + e.Message)
let cts = new CancellationTokenSource()
try
Async.RunSynchronously(work, 50, cts.Token)
with
| e -> Console.WriteLine (e.GetType().Name + ": " + e.Message)
cts.CancelAfter(80)
try
Async.RunSynchronously(work, 50, cts.Token)
with …Run Code Online (Sandbox Code Playgroud) 我正在使用rufus调度程序来执行一些任务.我希望在脚本启动时,或者在给定的时间间隔内,所有任务都会立即运行.这似乎没有API支持,或者我错过了什么?
我已经使用0.1秒作为延迟,直到第一次运行,如下所示
scheduler = Rufus::Scheduler.new
scheduler.every '10s', :first_in => 0.1 do
#do some work
end
Run Code Online (Sandbox Code Playgroud)
如果该:first_in属性设置为0,则在第一次运行之前,调度程序将等待整整10秒.如果该值设置得太低(我想在过去执行任务时评估的内容),或者如果我使用Time.now,则会引发以下错误:
~/.ruby/gems/rufus-scheduler-3.0.4/lib/rufus/scheduler/jobs.rb:383:in `first_at=': cannot set first[_at|_in] in the past: 1.0e-07 -> 2014-01-22 10:44:32 +0000 (ArgumentError)
from ~/.ruby/gems/rufus-scheduler-3.0.4/lib/rufus/scheduler/jobs.rb:445:in `first_at='
from ~/.ruby/gems/rufus-scheduler-3.0.4/lib/rufus/scheduler/jobs.rb:370:in `initialize'
from ~/.ruby/gems/rufus-scheduler-3.0.4/lib/rufus/scheduler/jobs.rb:457:in `initialize'
from ~/.ruby/gems/rufus-scheduler-3.0.4/lib/rufus/scheduler.rb:570:in `new'
from ~/.ruby/gems/rufus-scheduler-3.0.4/lib/rufus/scheduler.rb:570:in `do_schedule'
from ~/.ruby/gems/rufus-scheduler-3.0.4/lib/rufus/scheduler.rb:207:in `every'
from rufus_runner.rb:11:in `<main>'
Run Code Online (Sandbox Code Playgroud)
知道正确的方法是做什么的吗?
f# ×2
angular ×1
aws-cli ×1
jmespath ×1
logstash ×1
nuget ×1
ruby ×1
spring ×1
spring-boot ×1
testbed ×1
typescript ×1
validation ×1