Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add iexec-core-library subproject #623

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.

## [[NEXT]](https://github.com/iExecBlockchainComputing/iexec-core/releases/tag/vNEXT) 2023

### New Features
- Create `iexec-core-library` sub-project to split shared code/apis from specific scheduler application code. (#623)

## [[8.2.0]](https://github.com/iExecBlockchainComputing/iexec-core/releases/tag/v8.2.0) 2023-09-29

### New Features
41 changes: 20 additions & 21 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -8,8 +8,6 @@ plugins {
id 'maven-publish'
}

group = 'com.iexec.core'

ext {
springCloudVersion = '2021.0.8'
jjwtVersion = '0.11.5'
@@ -21,21 +19,28 @@ if (!project.hasProperty('gitBranch')) {
ext.gitBranch = 'git rev-parse --abbrev-ref HEAD'.execute().text.trim()
}

if (gitBranch != 'main' && gitBranch != 'master' && ! (gitBranch ==~ '(release|hotfix|support)/.*')) {
version += '-NEXT-SNAPSHOT'
}

repositories {
mavenLocal()
mavenCentral()
maven {
url "https://docker-regis-adm.iex.ec/repository/maven-public/"
credentials {
username nexusUser
password nexusPassword
allprojects {
group = 'com.iexec.core'
if (gitBranch != 'main' && gitBranch != 'master' && !(gitBranch ==~ '(release|hotfix|support)/.*')) {
version += '-NEXT-SNAPSHOT'
}
repositories {
mavenLocal()
mavenCentral()
maven {
url "https://docker-regis-adm.iex.ec/repository/maven-public/"
credentials {
username nexusUser
password nexusPassword
}
}
maven { url "https://jitpack.io" }
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}
maven { url "https://jitpack.io" }
}

dependencyManagement {
@@ -104,12 +109,6 @@ dependencies {
testImplementation "org.testcontainers:mongodb:$testContainersVersion"
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}

jar {
enabled = true
archiveClassifier.set('library')
48 changes: 48 additions & 0 deletions iexec-core-library/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
plugins {
id 'java-library'
id 'io.freefair.lombok'
id 'jacoco'
id 'maven-publish'
}

dependencies {
implementation "com.iexec.commons:iexec-commons-poco:$iexecCommonsPocoVersion"
implementation "com.iexec.common:iexec-common:$iexecCommonVersion"
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2'
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

java {
withJavadocJar()
withSourcesJar()
}


tasks.withType(Test).configureEach {
finalizedBy tasks.jacocoTestReport
useJUnitPlatform()
}

// sonarqube code coverage requires jacoco XML report
jacocoTestReport {
reports {
xml.required = true
}
}

publishing {
publications {
maven(MavenPublication) {
from components.java
}
}
repositories {
maven {
credentials {
username nexusUser
password nexusPassword
}
url = project.hasProperty("nexusUrl")? project.nexusUrl: ''
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright 2023-2023 IEXEC BLOCKCHAIN TECH
*
* 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.
*/

package com.iexec.core.api;

import com.iexec.common.config.PublicConfiguration;
import com.iexec.common.config.WorkerModel;
import com.iexec.common.replicate.ReplicateStatusUpdate;
import com.iexec.common.replicate.ReplicateTaskSummary;
import com.iexec.commons.poco.notification.TaskNotification;
import com.iexec.commons.poco.notification.TaskNotificationType;
import feign.Headers;
import feign.Param;
import feign.RequestLine;

import java.security.Signature;
import java.util.List;

public interface SchedulerClient {

@RequestLine("GET /version")
String getCoreVersion();

// region /workers
@RequestLine("GET /workers/challenge?walletAddress={walletAddress}")
String getChallenge(@Param("walletAddress") String walletAddress);

@RequestLine("POST /workers/login?walletAddress={walletAddress}")
String login(@Param("walletAddress") String walletAddress, Signature signature);

@RequestLine("POST /workers/ping")
@Headers("Authorization: {authorization}")
String ping(@Param("authorization") String authorization);

@RequestLine("POST /workers/register")
@Headers("Authorization: {authorization}")
void registerWorker(@Param("authorization") String authorization, WorkerModel model);

@RequestLine("GET /workers/config")
PublicConfiguration getPublicConfiguration();

@RequestLine("GET /workers/computing")
@Headers("Authorization: {authorization}")
List<String> getComputingTasks(@Param("authorization") String authorization);
// endregion

// region /replicates
@RequestLine("GET /replicates/available?blockNumber={blockNumber}")
@Headers("Authorization: {authorization}")
ReplicateTaskSummary getAvailableReplicateTaskSummary(
@Param("authorization") String authorization, @Param("blockNumber") long blockNumber);

@RequestLine("GET /replicates/interrupted?blockNumber={blockNumber}")
@Headers("Authorization: {authorization}")
List<TaskNotification> getMissedTaskNotifications(
@Param("authorization") String authorization, @Param("blockNumber") long blockNumber);

@RequestLine("POST /replicates/{chainTaskId}/updateStatus")
@Headers("Authorization: {authorization}")
TaskNotificationType updateReplicateStatus(
@Param("authorization") String authorization,
@Param("chainTaskId") String chainTaskId,
ReplicateStatusUpdate replicateStatusUpdate
);
// endregion
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2023-2023 IEXEC BLOCKCHAIN TECH
*
* 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.
*/

package com.iexec.core.api;

import com.iexec.common.utils.FeignBuilder;
import feign.Logger;

public class SchedulerClientBuilder {

private SchedulerClientBuilder() {}

public static SchedulerClient getInstance(Logger.Level logLevel, String url) {
return FeignBuilder.createBuilder(logLevel)
.target(SchedulerClient.class, url);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2023-2023 IEXEC BLOCKCHAIN TECH
*
* 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.
*/

package com.iexec.core.api;

import feign.Logger;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

class SchedulerClientTest {

@Test
void instantiationTest() {
Assertions.assertNotNull(SchedulerClientBuilder.getInstance(Logger.Level.FULL, "localhost"));
}

}
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
rootProject.name = 'iexec-core'
include 'iexec-core-library'