terrymanu commented on a change in pull request #1384: URL: https://github.com/apache/shardingsphere-elasticjob/pull/1384#discussion_r473118966
########## File path: elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/annotation/Mapping.java ########## @@ -0,0 +1,46 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.shardingsphere.elasticjob.restful.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Declare what HTTP method and path is used to invoke the handler. + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Mapping { + + /** + * Http method. + * + * @return Http method + */ + String method(); + + /** + * Path pattern of this handler. + * Such as <code>/app/{jobName}/enable</code>. + * + * @return Path pattern + */ + String pattern(); Review comment: I think so, it is better to keep same with famous framework, which can let user easy to understand. ########## File path: elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/NettyRestfulService.java ########## @@ -0,0 +1,75 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 org.apache.shardingsphere.elasticjob.restful; + +import com.google.common.base.Strings; +import io.netty.bootstrap.ServerBootstrap; +import io.netty.channel.ChannelFuture; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.nio.NioServerSocketChannel; +import lombok.extern.slf4j.Slf4j; +import org.apache.shardingsphere.elasticjob.restful.pipeline.RestfulServiceChannelInitializer; + +/** + * Implemented {@link RestfulService} via Netty. + */ +@Slf4j +public final class NettyRestfulService implements RestfulService { + + private final NettyRestfulServiceConfiguration configuration; + + private ServerBootstrap serverBootstrap; + + private EventLoopGroup eventLoopGroup; + + public NettyRestfulService(final NettyRestfulServiceConfiguration configuration) { + this.configuration = configuration; + } + + private void initServerBootstrap() { + eventLoopGroup = new NioEventLoopGroup(); + serverBootstrap = new ServerBootstrap() + .group(eventLoopGroup) Review comment: 1. Generally, separate boss and worker group is best practice. If no special reason, it is better separate them. 2. I prefer add default worker group size as `CPU * 2 + 1`, which can simplify user configuration and suitable for most scenario. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
