Categorygithub.com/crosect/cc-go
modulepackage
1.0.2
Repository: https://github.com/crosect/cc-go.git
Documentation: pkg.go.dev

# README

Golib

Common core for Golang project.

Setup instruction

Both go get and go mod are supported.

go get github.com/crosect/cc-go

Usage

Using fx.Option to include dependencies for injection.

See some simple examples:

Configuration

1. Environment variables

VarDefaultDescription
APP_PROFILES or APP_ENVlocalDefines the list of active profiles, separate by comma. By default, default profile is always load even this env configured.
Example: when APP_PROFILES=internal,uat then both default internal and uat will be loaded by order.
APP_CONFIG_PATHS./configDefines the location of config directory, when the application is started, it will scan profiles in this path.
APP_CONFIG_FORMATyamlDefines the format of config file. Currently we only support Yaml format (both yaml yml are accepted).

Besides, all our configs can be overridden by environment variables. For example:

store:
    name: Fruit store # Equivalent to STORE_NAME
    items:
        -   name: Apple # Equivalent to STORE_ITEMS_0_NAME
            price: 5 # Equivalent to STORE_ITEMS_0_PRICE
        -   name: Lemon # Equivalent to STORE_ITEMS_1_NAME
            price: 0.5 # Equivalent to STORE_ITEMS_1_PRICE

2. Available configurations

app:
    # Configuration available for AppOpt()
    name: Service Name # Specify application name. Default `unspecified`
    port: 8080 # Defines the running port. Default `8080`
    path: /service-base-path/ # Defines base path (context path). Default `/`

    # Configuration available for LoggingOpt()
    logging:
        development: false # Enable or disable development mode. Default `false`
        jsonOutputMode: true # Enable or disable json output. Default `true`

    # Configuration available for EventOpt()
    event:
        # Default event channel accept maximum 10 events,
        # other incoming events will be blocked until the channel has free space.
        channelSize: 10
        notLogPayloadForEvents:
            - OrderCreatedEvent
            - OrderUpdatedEvent

    # Configuration for HttpClientOpt()
    httpClient:
        timeout: 60s # Request timeout, in duration format. Default 60s
        maxIdleConns: 100 # Default 100
        maxIdleConnsPerHost: 10 # Default 10
        maxConnsPerHost: 100 # Default 100
        proxy:
            url: http://localhost:8080 # Proxy url
            appliedUris: # List of URIs, which will be requested under above proxy
                - https://foo.com/path/
                - https://bar.com/path/
    httpRequest:
        logging:
            disabled: false # Enable/disable all http request log
            predefinedDisabledUrls: # Shouldn't modify it, use disabledUrls instead
                - { urlPattern: "^/actuator/.*" } # By default, we disable all actuator requests
            disabledUrls: # Not log request for urls that matching method & url pattern
                - { method: "GET", urlPattern: "^/an-url-with-disabled-log/.*" }
                - { method: "POST", urlPattern: "^/another-url$" }

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewActuatorEndpoint Initiate actuator endpoint with health checker and informer automatically.
NewContextualHttpClient Initiate a client.ContextualHttpClient with configs are loaded automatically.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ProvideHealthChecker A simple way to provide a health checker.
ProvideInformer A simple way to provide an informer.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
WithFormat accept yaml, json values.
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author