-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HCHttp refactoring - splitting HCHttp and ClientObjectFactory (#60)
* BatchingClientObjectFactory added to separate batching logic from HCHttp * Batch and Item interfaces added (finally!) to handle API-specific implementations of "Batch domain" * BatchOperations can now be configured with HCHttp.Builder (configurable provider of "Batch domain") * HCHttp.Builder.pooledItemSourceFactory deprecated * HCHttp.itemSourceFactory removed * HCHttp.Builder.mappingType deprecated * HCHttp.mappingType removed * OperationFactory MUST be provided
- Loading branch information
Showing
23 changed files
with
1,557 additions
and
871 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...ticsearch-core/src/main/java/org/appenders/log4j2/elasticsearch/BatchListenerFactory.java
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,41 @@ | ||
package org.appenders.log4j2.elasticsearch; | ||
|
||
/*- | ||
* #%L | ||
* log4j2-elasticsearch | ||
* %% | ||
* Copyright (C) 2021 Rafal Foltynski | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
|
||
import java.util.function.Function; | ||
|
||
public interface BatchListenerFactory<BATCH_TYPE> { | ||
|
||
/** | ||
* Listener that MUST accept and send prepared batch and handle the exceptions | ||
* @param failoverPolicy sink for failed batch items | ||
* @return prepared batch handler | ||
*/ | ||
Function<BATCH_TYPE, Boolean> createBatchListener(FailoverPolicy failoverPolicy); | ||
|
||
/** | ||
* Failed batch handler. SHOULD deliver the batch to alternate target or provided failover policy | ||
* @param failover optional failover strategy | ||
* @return prepared failed batch handler | ||
*/ | ||
Function<BATCH_TYPE, Boolean> createFailureHandler(FailoverPolicy failover); | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
...j2-elasticsearch-core/src/main/java/org/appenders/log4j2/elasticsearch/ClientFactory.java
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,37 @@ | ||
package org.appenders.log4j2.elasticsearch; | ||
|
||
/*- | ||
* #%L | ||
* log4j2-elasticsearch | ||
* %% | ||
* Copyright (C) 2021 Rafal Foltynski | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
|
||
import java.util.Collection; | ||
|
||
public interface ClientFactory<CLIENT_TYPE> { | ||
|
||
/** | ||
* @return Collection of configured addresses | ||
*/ | ||
Collection<String> getServerList(); | ||
|
||
/** | ||
* @return CLIENT_TYPE Fully configured client | ||
*/ | ||
CLIENT_TYPE createClient(); | ||
|
||
} |
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
28 changes: 28 additions & 0 deletions
28
log4j2-elasticsearch-hc/src/main/java/org/appenders/log4j2/elasticsearch/hc/Batch.java
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,28 @@ | ||
package org.appenders.log4j2.elasticsearch.hc; | ||
|
||
/*- | ||
* #%L | ||
* log4j2-elasticsearch | ||
* %% | ||
* Copyright (C) 2021 Rafal Foltynski | ||
* %% | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* #L% | ||
*/ | ||
|
||
import java.util.Collection; | ||
|
||
public interface Batch<I> extends Request { | ||
Collection<I> getItems(); | ||
void completed(); | ||
} |
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
Oops, something went wrong.