github.com/gramework/gramework@v1.8.1-0.20231027140105-82555c9057f5/x/client/types.go (about)

     1  // Copyright 2017-present Kirill Danshin and Gramework contributors
     2  // Copyright 2019-present Highload LTD (UK CN: 11893420)
     3  //
     4  // Licensed under the Apache License, Version 2.0 (the "License");
     5  // you may not use this file except in compliance with the License.
     6  // You may obtain a copy of the License at
     7  //
     8  //     http://www.apache.org/licenses/LICENSE-2.0
     9  //
    10  
    11  package client
    12  
    13  import (
    14  	"sync"
    15  	"time"
    16  
    17  	"github.com/valyala/fasthttp"
    18  )
    19  
    20  type (
    21  	// Instance handles internal client representation and settings
    22  	Instance struct {
    23  		conf      *Config
    24  		clients   map[string]*fasthttp.HostClient
    25  		clientsMu *sync.RWMutex
    26  		balancer  *rangeBalancer
    27  	}
    28  
    29  	// Config handles APIClient parameters
    30  	Config struct {
    31  		Addresses       []string
    32  		WatcherTickTime time.Duration
    33  	}
    34  
    35  	rangeBalancer struct {
    36  		total *int64
    37  		curr  *int64
    38  	}
    39  
    40  	requestInfo struct {
    41  		HostClient *fasthttp.HostClient
    42  		Addr       string
    43  	}
    44  )