Service/Protocol

You can expose existing services or implement the corresponding protocol yourself to expose services externally

Detailed examples referenceherearrow-up-right

Implemented services

public configuration

## Service-related configuration
asjard:
  ## Multi-protocol service related configuration
  ## Not effective in real time, restart required after modification
  servers:
    ## Protocol-agnostic server interceptor list, multiple interceptors separated by commas (,)
    # interceptors: ""
    ## Built-in configured interceptors
    # builtInInterceptors:
    #   - ratelimiter
    #   - metrics
    #   - accessLog
    #   - restReadEntity
    #   - restResponseHeader
    #   - i18n
    #   - trace
    ## Default handlers
    # defaultHandlers: ""
    ## Built-in configured default handlers
    # builtInDefaultHandlers:
    #   - health
    #   - metrics
    ## Certificate file path, relative to ASJARD_CERT_DIR
    certFile: ""
    ## Private key file path, relative to ASJARD_CERT_DIR
    keyFile: ""

How to implement your own service

Configuration conventions

  • Configurations should all be placed underasjard.servers.{custom service name}Under this namespace

Custom service

For specifics refer tocore/server/server.goin the code

  • You need to implement the following two methods

  • Then viaAddServeradd the service

  • Refer to the concrete implementationpkg/server/rest,pkg/server/grpc,pkg/server/pprof

Use

  • Step one: Write the protobuf definition file, for details please refer toprotobuf

  • Step two: Compile the proto file

  • Step three: Write the service

  • The above three steps are the entire process to write and start a service

  • For configuration and access details refer togrpc serviceandrest service

Last updated