config.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package consul
  2. var _ DefaultServiceInstance = (*serviceInstance)(nil)
  3. type DefaultServiceInstance interface {
  4. GetInstanceID() string
  5. GetServiceID() string
  6. GetHost() string
  7. GetPort() int
  8. IsSecure() bool
  9. GetMetadata() map[string]string
  10. }
  11. type serviceInstance struct {
  12. InstanceID string
  13. ServiceID string
  14. Host string
  15. Port int
  16. Secure bool
  17. Metadata map[string]string
  18. }
  19. func NewDefaultServiceInstance(serviceID string, host string, port int, secure bool,
  20. metadata map[string]string, instanceID string) (DefaultServiceInstance, error) {
  21. return &serviceInstance{
  22. InstanceID: instanceID,
  23. ServiceID: serviceID,
  24. Host: host,
  25. Port: port,
  26. Secure: secure,
  27. Metadata: metadata,
  28. }, nil
  29. }
  30. func (serviceInstance serviceInstance) GetInstanceID() string {
  31. return serviceInstance.InstanceID
  32. }
  33. func (serviceInstance serviceInstance) GetServiceID() string {
  34. return serviceInstance.ServiceID
  35. }
  36. func (serviceInstance serviceInstance) GetHost() string {
  37. return serviceInstance.Host
  38. }
  39. func (serviceInstance serviceInstance) GetPort() int {
  40. return serviceInstance.Port
  41. }
  42. func (serviceInstance serviceInstance) IsSecure() bool {
  43. return serviceInstance.Secure
  44. }
  45. func (serviceInstance serviceInstance) GetMetadata() map[string]string {
  46. return serviceInstance.Metadata
  47. }