All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.fashionbrot.ribbon.loadbalancer.Server Maven / Gradle / Ivy

Go to download

mars-ribbon-api 负载均衡工具 https://github.com/fashionbrot/mars-dynamic-config

There is a newer version: 0.1.3
Show newest version
package com.github.fashionbrot.ribbon.loadbalancer;

import com.github.fashionbrot.ribbon.constants.GlobalConstants;
import com.github.fashionbrot.ribbon.enums.SchemeEnum;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author fashionbrot
 * @version 0.1.0
 * @date 2019/12/8 22:45
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Server {

    private String host;

    private int port = 80;

    private SchemeEnum scheme;

    private String path ;

    public String getServer(){

        if (scheme==SchemeEnum.HTTP){
            if (path == null || path.length()==0){
                return GlobalConstants.HTTP_SCHEME+host+":"+port;
            }
            return GlobalConstants.HTTP_SCHEME+host+":"+port + "/"+path;
        }else{
            if (path == null || path.length()==0) {
                return GlobalConstants.HTTPS_SCHEME + host + ":" + port;
            }
            return GlobalConstants.HTTPS_SCHEME + host + ":" + port + "/" + path;
        }
    }

    public String getServerIp(){
        return this.host+":"+port;
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy