apollo_client

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2022 License: MIT Imports: 6 Imported by: 0

README

easy-apollo-client

an apollo client for sync local changes to remote inspired by agollo

example

see example.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddConfReq

type AddConfReq struct {
	Key                 string `json:"key"`
	Value               string `json:"value"`
	Comment             string `json:"comment"`
	DataChangeCreatedBy string `json:"dataChangeCreatedBy"`
}

type AddConfResp

type AddConfResp struct {
	Key                        string `json:"key"`
	Value                      string `json:"value"`
	Comment                    string `json:"comment"`
	DataChangeCreatedBy        string `json:"dataChangeCreatedBy"`
	DataChangeLastModifiedBy   string `json:"dataChangeLastModifiedBy"`
	DataChangeCreatedTime      string `json:"dataChangeCreatedTime"`
	DataChangeLastModifiedTime string `json:"dataChangeLastModifiedTime"`
}

type ApolloApiClient

type ApolloApiClient struct {
	// contains filtered or unexported fields
}

func NewApolloApiClient

func NewApolloApiClient(resty *resty.Client, creator string) *ApolloApiClient

func (*ApolloApiClient) AddConf

func (c *ApolloApiClient) AddConf(env, appId, clusterName, namespace, key, value string) (*AddConfResp, error)

func (*ApolloApiClient) DeleteConf

func (c *ApolloApiClient) DeleteConf(env, appId, clusterName, namespace, key string) error

func (*ApolloApiClient) GetConf

func (c *ApolloApiClient) GetConf(env, appId, clusterName, namespace, key string) (*GetConfResp, error)

func (*ApolloApiClient) GetNameSpaceInfo

func (c *ApolloApiClient) GetNameSpaceInfo(env, appId, clusterName, namespace string) (*NameSpaceInfoResp, error)

func (*ApolloApiClient) GetReleasedConf

func (c *ApolloApiClient) GetReleasedConf(env, appId, clusterName, namespace string) (*GetReleasedConfResp, error)

func (*ApolloApiClient) ReleaseConf

func (c *ApolloApiClient) ReleaseConf(env, appId, clusterName, namespace string) (*ReleaseConfResp, error)

func (*ApolloApiClient) UpdateConf

func (c *ApolloApiClient) UpdateConf(env, appId, clusterName, namespace, key, value string) error

type ApolloCache

type ApolloCache struct {
	// contains filtered or unexported fields
}

func NewApolloCache

func NewApolloCache() *ApolloCache

func (*ApolloCache) Delete

func (c *ApolloCache) Delete(key string)

func (*ApolloCache) Get

func (c *ApolloCache) Get(key string) (value string, ok bool)

func (*ApolloCache) Range

func (c *ApolloCache) Range(rangeFunc func(key, value string) bool)

func (*ApolloCache) Set

func (c *ApolloCache) Set(key string, value string)

type ApolloClient

type ApolloClient struct {
	Conf ApolloConfig
	// contains filtered or unexported fields
}

ApolloClient an apollo client sync local to remote

func NewApolloClient

func NewApolloClient(conf ApolloConfig, creator string) (*ApolloClient, error)

NewApolloClient create a apollo client

func (*ApolloClient) AutoSync

func (c *ApolloClient) AutoSync(duration time.Duration) error

AutoSync this will start auto sync, call AutoSync function every interval

func (*ApolloClient) DeleteKey

func (c *ApolloClient) DeleteKey(key string)

DeleteKey delete key from cache

func (*ApolloClient) GetCache

func (c *ApolloClient) GetCache() *ApolloCache

GetCache GetKeys get local cache

func (*ApolloClient) GetKey

func (c *ApolloClient) GetKey(key string) (string, bool)

GetKey get key value from cache

func (*ApolloClient) SetConf

func (c *ApolloClient) SetConf(conf ApolloConfig)

SetConf set apollo config

func (*ApolloClient) SetKey

func (c *ApolloClient) SetKey(key, value string)

SetKey set key value to cache

func (*ApolloClient) StopAutoSync

func (c *ApolloClient) StopAutoSync()

StopAutoSync this will stop auto sync

func (*ApolloClient) Sync

func (c *ApolloClient) Sync() error

Sync this will sync local cache to remote

func (*ApolloClient) SyncFromRemote

func (c *ApolloClient) SyncFromRemote() error

SyncFromRemote this will sync the cache from remote

func (*ApolloClient) UpdateKey

func (c *ApolloClient) UpdateKey(key, value string)

UpdateKey update key value to cache

type ApolloConfig

type ApolloConfig struct {
	Host       string //访问地址
	AppId      string //应用id
	NameSpace  string //命名空间
	Env        string //环境信息
	Cluster    string //集群名称
	Token      string //Token
	RetryCount uint   //重试次数
	Timeout    uint   //超时时间
}

type GetConfResp

type GetConfResp struct {
	Key                        string `json:"key"`
	Value                      string `json:"value"`
	Comment                    string `json:"comment"`
	DataChangeCreatedBy        string `json:"dataChangeCreatedBy"`
	DataChangeLastModifiedBy   string `json:"dataChangeLastModifiedBy"`
	DataChangeCreatedTime      string `json:"dataChangeCreatedTime"`
	DataChangeLastModifiedTime string `json:"dataChangeLastModifiedTime"`
}

type GetReleasedConfResp

type GetReleasedConfResp struct {
	AppId                      string                 `json:"appId"`
	ClusterName                string                 `json:"clusterName"`
	NamespaceName              string                 `json:"namespaceName"`
	Name                       string                 `json:"name"`
	Configurations             map[string]interface{} `json:"configurations"`
	Comment                    string                 `json:"comment"`
	DataChangeCreatedBy        string                 `json:"dataChangeCreatedBy"`
	DataChangeLastModifiedBy   string                 `json:"dataChangeLastModifiedBy"`
	DataChangeCreatedTime      string                 `json:"dataChangeCreatedTime"`
	DataChangeLastModifiedTime string                 `json:"dataChangeLastModifiedTime"`
}

type NameSpaceInfoResp

type NameSpaceInfoResp struct {
	AppId         string `json:"appId"`
	ClusterName   string `json:"clusterName"`
	NamespaceName string `json:"namespaceName"`
	Comment       string `json:"comment"`
	Format        string `json:"format"`
	IsPublic      bool   `json:"isPublic"`
	Items         []struct {
		Key                        string `json:"key"`
		Value                      string `json:"value"`
		DataChangeCreatedBy        string `json:"dataChangeCreatedBy"`
		DataChangeLastModifiedBy   string `json:"dataChangeLastModifiedBy"`
		DataChangeCreatedTime      string `json:"dataChangeCreatedTime"`
		DataChangeLastModifiedTime string `json:"dataChangeLastModifiedTime"`
	} `json:"items"`
	DataChangeCreatedBy        string `json:"dataChangeCreatedBy"`
	DataChangeLastModifiedBy   string `json:"dataChangeLastModifiedBy"`
	DataChangeCreatedTime      string `json:"dataChangeCreatedTime"`
	DataChangeLastModifiedTime string `json:"dataChangeLastModifiedTime"`
}

type ReleaseConfReq

type ReleaseConfReq struct {
	ReleaseTitle   string `json:"releaseTitle"`
	ReleaseComment string `json:"releaseComment"`
	ReleasedBy     string `json:"releasedBy"`
}

type ReleaseConfResp

type ReleaseConfResp struct {
	AppId                      string                 `json:"appId"`
	ClusterName                string                 `json:"clusterName"`
	NamespaceName              string                 `json:"namespaceName"`
	Name                       string                 `json:"name"`
	Configurations             map[string]interface{} `json:"configurations"`
	Comment                    string                 `json:"comment"`
	DataChangeCreatedBy        string                 `json:"dataChangeCreatedBy"`
	DataChangeLastModifiedBy   string                 `json:"dataChangeLastModifiedBy"`
	DataChangeCreatedTime      string                 `json:"dataChangeCreatedTime"`
	DataChangeLastModifiedTime string                 `json:"dataChangeLastModifiedTime"`
}

type UpdateConfReq

type UpdateConfReq struct {
	Key                      string `json:"key"`
	Value                    string `json:"value"`
	Comment                  string `json:"comment"`
	DataChangeLastModifiedBy string `json:"dataChangeLastModifiedBy"`
}

Jump to

Keyboard shortcuts

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