Giter Club home page Giter Club logo

Comments (7)

philchia avatar philchia commented on August 23, 2024

client.Start() will not block when namespace absent

from agollo.

philchia avatar philchia commented on August 23, 2024

what is your apollo server version?

from agollo.

leikao avatar leikao commented on August 23, 2024

what is your apollo server version?

v0.11.0 @philchia

from agollo.

leikao avatar leikao commented on August 23, 2024

Apollo will hold the request up to 60 seconds according to this wiki page

from agollo.

philchia avatar philchia commented on August 23, 2024

The initial request to this url will pass -1 as notificationId, so this request never blocks

from agollo.

leikao avatar leikao commented on August 23, 2024

It will block for at least 60 seconds if the namespace is absent, you can try it:

package main

import (
    "time"
    "fmt"
    "net/url"
    "net/http"
)

const (
    ApolloServerEndpoint = "http://x.x.x.x:8080"   // Apollo Config Server Endpoint
    HttpClientTimeout = time.Second * 90    // Notification will timeout if < 60s when namespace absent.
)

func main() {
    testAgollo("xxx", "default", "switch")
    testAgollo("xxx", "default", "not-exists")
    testAgollo("xxx", "default", "switch")
}

func testAgollo(app, cluster, ns string) {
    t := time.Now()
    defer func() {
        fmt.Printf(">>>\tTime cost for namespace (%s): %v\n", ns, time.Since(t))
    }()

    u, _ := url.Parse(ApolloServerEndpoint)
    u, _ = u.Parse("/notifications/v2")

    req, _ := http.NewRequest(http.MethodGet, u.String(), nil)
    args := req.URL.Query()
    args.Add("appId", app)
    args.Add("cluster", cluster)
    args.Add("notifications", fmt.Sprintf("[{\"namespaceName\": \"%s\", \"notificationId\":-1}]", ns))
    req.URL.RawQuery = args.Encode()

    c := http.Client{Timeout: HttpClientTimeout}
    rsp, e := c.Do(req)
    if e != nil {
        fmt.Println("failed to send request to apollo: ", e)
        return
    }
    fmt.Println("apollo response code: ", rsp.StatusCode)
    return
}

from agollo.

philchia avatar philchia commented on August 23, 2024

You need to query all namesapce in one request, as the application namespace is the defaut namespace, so this request will return ASAP without block

from agollo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.