All Projects → xiaooloong → lua-resty-eureka-client

xiaooloong / lua-resty-eureka-client

Licence: other
A Netflix Eureka client for OpenResty/ngx_lua

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to lua-resty-eureka-client

Spring Cloud Cli
Spring Cloud CLI features
Stars: ✭ 139 (+672.22%)
Mutual labels:  spring-cloud, eureka
sample-spring-cloud-gateway
sample spring cloud application with embedded api gateway on spring cloud gateway with or without service discovery with eureka
Stars: ✭ 25 (+38.89%)
Mutual labels:  spring-cloud, eureka
Spring Boot Cloud
基于 Spring Boot、Spring Cloud、Spring Oauth2 和 Spring Cloud Netflix 等框架构建的微服务项目
Stars: ✭ 2,044 (+11255.56%)
Mutual labels:  spring-cloud, eureka
Eureka Consul Adapter
This project contains a Spring Boot Starter that registers HTTP endpoints on a Spring Cloud Eureka server to support Prometheus's service discovery mechanism for Consul (<consul_sd_config>)
Stars: ✭ 93 (+416.67%)
Mutual labels:  spring-cloud, eureka
Advanced Java
😮 Core Interview Questions & Answers For Experienced Java(Backend) Developers | 互联网 Java 工程师进阶知识完全扫盲:涵盖高并发、分布式、高可用、微服务、海量数据处理等领域知识
Stars: ✭ 59,142 (+328466.67%)
Mutual labels:  spring-cloud, eureka
Python Eureka Client
A eureka client written in python. Support registering your python component to Eureka Server, as well as calling remote services by pulling the the Eureka registry.
Stars: ✭ 111 (+516.67%)
Mutual labels:  spring-cloud, eureka
Springcloud Shop
基于Spring Boot、Spring Cloud的微服务商城demo
Stars: ✭ 198 (+1000%)
Mutual labels:  spring-cloud, eureka
Sample Spring Cloud Webflux
sample microservices demonstrating usage of spring reactive support with spring webflux and integration spring cloud, eureka, ribbon, spring cloud gateway, spring data jpa and mongodb
Stars: ✭ 65 (+261.11%)
Mutual labels:  spring-cloud, eureka
Springcloudlearning
《史上最简单的Spring Cloud教程源码》
Stars: ✭ 16,218 (+90000%)
Mutual labels:  spring-cloud, eureka
Springcloud
springCloud学习
Stars: ✭ 251 (+1294.44%)
Mutual labels:  spring-cloud, eureka
Genesis
Spring cloud Example
Stars: ✭ 83 (+361.11%)
Mutual labels:  spring-cloud, eureka
spring-projects
Some spring sample projects
Stars: ✭ 24 (+33.33%)
Mutual labels:  spring-cloud, eureka
Fxshop
基于SpringBoot+SpringCloud微服务的商城项目(demo版 不可用于生产)
Stars: ✭ 82 (+355.56%)
Mutual labels:  spring-cloud, eureka
Spring Cloud
SpringCloud微服务架构,提供快速上手脚手架,快速构建高可用注册中心,高可用配置中心,加入Hystrix断路器,gateway服务官网,权限认证、服务降级、限流,加入应用监控
Stars: ✭ 130 (+622.22%)
Mutual labels:  spring-cloud, eureka
Microservices Example
Example of a microservices architecture on the modern stack of Java technologies
Stars: ✭ 66 (+266.67%)
Mutual labels:  spring-cloud, eureka
Edc.springcloud.samples
Spring Cloud作为第二代微服务的代表性框架,已经在国内众多大中小型的公司有实际应用案例。许多公司的业务线全部拥抱Spring Cloud,部分公司选择部分拥抱Spring Cloud。此示例基于Spring Boot 1.5.x编写,展示了Spring Cloud的核心组件的基本使用方式,在学习Spring Cloud时可以参考本示例。
Stars: ✭ 183 (+916.67%)
Mutual labels:  spring-cloud, eureka
Mini Platform
Mini-Platform致力于更简洁易用的轻量级微服务治理平台。
Stars: ✭ 45 (+150%)
Mutual labels:  spring-cloud, eureka
Bookstoreapp Distributed Application
Ecommerce project is being developed using Spring Boot Microservices and Spring Cloud (Backend) and React (Frontend). Splitting the Ecommerce functionality into various individual microservices so that they can be distributed, scale really well and make use of resources efficiently.
Stars: ✭ 63 (+250%)
Mutual labels:  spring-cloud, eureka
Springcloudexamples
Spring Cloud 学习教程
Stars: ✭ 208 (+1055.56%)
Mutual labels:  spring-cloud, eureka
spring-microservices
Example of a microservice architecture using Spring Cloud
Stars: ✭ 76 (+322.22%)
Mutual labels:  spring-cloud, eureka

Netflix Eureka client for Openresty/ngx_lua

is a Netflix Eureka client written for OpenResty.

Inspired by PavelLoparev/php-eureka-client.

Nginx Worker Service

Using eureka.workerservice to register nginx itself to Eureka

workerservice:run(eurekaserver, instancedata)
init_worker_by_lua_block {
    (require 'eureka.workerservice'):run({
        host = '127.0.0.1',     -- eureka server address
        port = 8761,            -- eureka server port
        uri  = '/eureka/v2',    -- eureka server context uri, like '/eureka' or '/'
        timeval = 15,           -- heartbeat time interval in second, default value is 30s
        auth = {                -- optional, use it if your eureka server require http basic auth :)
            username = '',
            password = '',
        },
    },
        instancedata            -- eureka instance data, see 'InstanceData Builder'
    )
}

Client APIs

client:new(host, port, uri)

return the eureka client instance which uses eureka server at http://{host}:{port}{uri}, for example :

local eureka = require 'eureka.client'
local client, err = eureka:new(
                                '127.0.0.1',    -- add 'resolver' directive in nginx.conf if using domainname
                                8761,           -- port number
                                '/eureka/v2',   -- eureka server context uri, like '/eureka' or '/'
                                {               -- optional, use it if your eureka server require http basic auth :)
                                    username = '',
                                    password = '',
                                }
                            )
if not client then
    print('failed to create eureka client instance : ' .. err)
end

In case of error, nil will be returned as well as a string describing the error

client:register(appid, instancedata)

register new application instance to eureka server, appid is a string holding the name of your app

instancedata is a lua table conforms to this XSD, which you can build by eureka.instance

in case of success, true will be returned

in case of application or network error, nil will be returned as well as a string describing the error

in case of eureka server error, false will be returned as well as a string describing the error

client:heartBeat(appid, instanceid)

send application instance heartbeat for appid/instanceid

in case of success, a json string will be returned

in case of application or network error, nil will be returned as well as a string describing the error

in case of eureka server error, false will be returned as well as a string describing the error

if instanceid does not exist, ngx.null will be returned

client:deRegister(appid, instanceid)

de-register application instance for appid/instanceid

in case of success, true will be returned

in case of application or network error, nil will be returned as well as a string describing the error

in case of eureka server error, false will be returned as well as a string describing the error

client:getAllApps()

query for all instances registed in eureka server

in case of success, a json string will be returned

in case of application or network error, nil will be returned as well as a string describing the error

in case of eureka server error, false will be returned as well as a string describing the error

client:getApp(appid)

query for all appid instances

in case of success, a json string will be returned

in case of application or network error, nil will be returned as well as a string describing the error

in case of eureka server error, false will be returned as well as a string describing the error

client:getAppInstance(appid, instanceid)

query for a specific appid/instanceid

in case of success, a json string will be returned

in case of application or network error, nil will be returned as well as a string describing the error

in case of eureka server error, false will be returned as well as a string describing the error

client:getInstance(instanceid)

query for a specific instanceid

in case of success, a json string will be returned

in case of application or network error, nil will be returned as well as a string describing the error

in case of eureka server error, false will be returned as well as a string describing the error

client:getInstanceByVipAddress(vipaddress)

query for all instances under a particular vipaddress

in case of success, a json string will be returned

in case of application or network error, nil will be returned as well as a string describing the error

in case of eureka server error, false will be returned as well as a string describing the error

if vipaddress does not exist, ngx.null will be returned

client:getInstancesBySecureVipAddress(vipaddress)

query for all instances under a particular secure vipaddress

in case of success, a json string will be returned

in case of application or network error, nil will be returned as well as a string describing the error

in case of eureka server error, false will be returned as well as a string describing the error

if vipaddress does not exist, ngx.null will be returned

client:takeInstanceOut(appid, instanceid)

take instance out of service for appid/instanceid

in case of success, a json string will be returned

in case of failure, ngx.null will be returned

in case of application or network error, nil will be returned as well as a string describing the error

in case of eureka server error, false will be returned as well as a string describing the error

client:putInstanceBack(appid, instanceid)

move instance back into service for appid/insanceid

in case of success, true will be returned

in case of failure, ngx.null will be returned

in case of application or network error, nil will be returned as well as a string describing the error

in case of eureka server error, false will be returned as well as a string describing the error

client:removeOverriddenStatus(appid, instanceid)

remove the overriddenstatus for appid/instanceid

in case of success, true will be returned

in case of failure, ngx.null will be returned

in case of application or network error, nil will be returned as well as a string describing the error

in case of eureka server error, false will be returned as well as a string describing the error

client:updateAppInstanceMetadata(appid, instanceid, metadata)

update metadata for appid/instanceid

instancedata is a lua table holding key-value pairs to be set.

in case of success, true will be returned

in case of failure, ngx.null will be returned

in case of application or network error, nil will be returned as well as a string describing the error

in case of eureka server error, false will be returned as well as a string describing the error

InstanceData Builder

these following methods are used to build instancedata

use instance:new() to create new instancedata object

then use instance:set* to set attributes

finally use instance:export() to dump a lua table, which will be used at client:register()

  • instance:export()
  • instance:new()
  • instance:setInstanceId(string)
  • instance:setHostName(string)
  • instance:setApp(string)
  • instance:setIpAddr(string)
  • instance:setVipAddress(string)
  • instance:setSecureVipAddress(string)
  • instance:setStatus(string)
  • instance:setPort(number, enabled)
  • instance:setSecurePort(number, enabled)
  • instance:setHomePageUrl(string)
  • instance:setStatusPageUrl(string)
  • instance:setHealthCheckUrl(string)
  • instance:setDataCenterInfo(name, class, metadata)
  • instance:setLeaseInfo(table)
  • instance:setMetadata(table)

for example:

local i = require 'eureka.instance'
local ins = i:new()

local app = 'ngx-eureka-service'
local host = 'localhost'
local ip = '127.0.0.1'

ins:setInstanceId(('%s:%s:%s'):format(ip, app, ngx.worker.pid()))
ins:setHostName(host):setApp(app:upper())
ins:setIpAddr(host):setVipAddress(host)
ins:setStatus('UP'):setPort(80, true):setSecurePort(443, false)
ins:setHomePageUrl('http://' .. host):setStatusPageUrl('http://' .. host .. '/status')
ins:setHealthCheckUrl('http://' .. host .. '/check')
ins:setDataCenterInfo('Amazon', 'com.netflix.appinfo.AmazonInfo', {
    data_center_test_key = 'data_center_test_value'
})
ins:setLeaseInfo({
    evictionDurationInSecs = 60,
})
ins:setMetadata({
    language = 'ngx_lua'
})
local ok, err = client:register(app:upper(), ins:export())

Prerequisites

This library requires pintsized/lua-resty-http to be installed.

See Also

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].