public class S3MappingSource implements MappingsSource {
@Override
public void save(StubMapping stubMapping) {
storeToS3(stubMapping.getId().toString(), StubMapping.buildJsonStringFor(stubMapping));
}
@Override
public void loadMappingsInto(StubMappings stubMappings) {
var s3Objects = getAllFromS3();
s3Objects.stream()
.map(value -> StubMapping.buildFrom(value.getValueBytes().toStringUtf8()))
.filter(Objects::nonNull)
.forEach(stubMappings::addMapping);
}
@Override
public void remove(StubMapping stubMapping) {
throw new IllegalStateException("Not allowed");
}
@Override
public void removeAll() {
throw new IllegalStateException("Not allowed");
}
}
new WireMockServer(
WireMockConfiguration.wireMockConfig()
.port(mockConfiguration.getPort())
.mappingSource(new S3MappingSource());
--
You received this message because you are subscribed to a topic in the Google Groups "wiremock-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wiremock-user/mPj6YlrdVkM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wiremock-use...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/wiremock-user/90af2490-73be-436f-97f6-3a4e60139c6f%40googlegroups.com.
Hi Tom,Thanks for the reply. This is nice. Since I am implementing a custom MappingSource which doesn't use a FileSource, should I do something about it? I see that WireMock is loading a SingleRootFileSource by default, will it cause any problem?Thanks,
To unsubscribe from this group and all its topics, send an email to wiremock-user+unsubscribe@googlegroups.com.
+--------+ +--------------+ +---------------+| | | | | || A +------>+ WireMock +--->+ External API || | | | | |+--------+ +------+-------+ +---------------+ | | | | v
Kafka
If you don't create any stubs that use the bodyFileName attribute then you'll be fine. But if you do want to use that you could also implement a FileSource that backs on to S3. The main benefit of that would be that you'd save on heap space since you wouldn't be holding bodies in memory, but I'd only recommend doing that if you're serving large responses (> a few hundred KB).
On Wednesday, 3 June 2020 12:51:39 UTC+1, Dalton Fury wrote:
Hi Tom,Thanks for the reply. This is nice. Since I am implementing a custom MappingSource which doesn't use a FileSource, should I do something about it? I see that WireMock is loading a SingleRootFileSource by default, will it cause any problem?Thanks,
To unsubscribe from this group and all its topics, send an email to wiremo...@googlegroups.com.
If you don't create any stubs that use the bodyFileName attribute then you'll be fine. But if you do want to use that you could also implement a FileSource that backs on to S3. The main benefit of that would be that you'd save on heap space since you wouldn't be holding bodies in memory, but I'd only recommend doing that if you're serving large responses (> a few hundred KB).
On Wednesday, 3 June 2020 12:51:39 UTC+1, Dalton Fury wrote:
Hi Tom,Thanks for the reply. This is nice. Since I am implementing a custom MappingSource which doesn't use a FileSource, should I do something about it? I see that WireMock is loading a SingleRootFileSource by default, will it cause any problem?Thanks,
To unsubscribe from this group and all its topics, send an email to wiremo...@googlegroups.com.
wireMockServer.startRecording(mockServerConfiguration.getTargetUrl())