acm

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetServiceIPs

func GetServiceIPs(cl *http.Client, uri string) (ips []string, err error)

GetServiceIPs gets the IPs for a certain service specified by the uri.

func MD5

func MD5(bs []byte) string

MD5 returns the md5 string.

func Request

func Request(cl *http.Client, req *http.Request, ak *AccessKey, opt ConfigOption, timestamp string) (data []byte, err error)

Request sends an ACM API. Only data bytes of a 200 OK response will be returned.

func Timestamp

func Timestamp() string

Timestamp returns a timestamp string in ms.

Types

type AccessKey

type AccessKey sts.Credentials

AccessKey is an alias for sts.Credentials that used to sign the ACM APIs.

func (*AccessKey) Sign

func (k *AccessKey) Sign(content string) string

Sign signs the content as described in https://help.aliyun.com/document_detail/64129.html.

type ConfigOption

type ConfigOption struct {
	DataID string
	Group  string
	Tenant string // a.k.a. namespace
	MD5    string // for listen only
}

ConfigOption specifies a certain config.

func ParseListenResponse

func ParseListenResponse(resp []byte) (changed []ConfigOption)

ParseListenResponse gets the changed config(s).

func (ConfigOption) Join

func (o ConfigOption) Join() string

Join returns a string form of the ConfigOption as `dataId^2group^2contentMD5^2tenant^1`.

type Service

type Service struct {
	Host        string
	Port        string
	Path4IPs    string
	Path4Config string
	// Cl is used for all requests except for listenConfig.
	Cl *http.Client
	// Listener is for listenConfig which performs long polling.
	Listener *http.Client
}

Service is the config service.

func New

func New(host string) Service

New returns an ACM Service with default port & path setting. Get the endpoint from https://help.aliyun.com/document_detail/64129.html.

func (*Service) GetConfig

func (s *Service) GetConfig(ak *AccessKey, opt ConfigOption) ([]byte, error)

GetConfig gets the specific config from ACM. https://help.aliyun.com/document_detail/64131.html

func (*Service) GetIPs

func (s *Service) GetIPs() (ips []string, err error)

GetIPs gets the diamond service IPs.

func (*Service) ListenConfig

func (s *Service) ListenConfig(ak *AccessKey, opt ConfigOption) (resp []byte, err error)

ListenConfig listens for the changed config(s). https://help.aliyun.com/document_detail/64132.html

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL