micro--go-micro
1bb25d6e7f
* feat: add agent platform showcase and blog post Add a complete platform example (Users, Posts, Comments, Mail) that mirrors micro/blog, demonstrating how existing microservices become AI-accessible through MCP with zero code changes. Includes blog post "Your Microservices Are Already an AI Platform" walking through real agent workflows: signup, content creation, commenting, tagging, and cross-service messaging. https://claude.ai/code/session_01GkduEhcrqcG45rdfYh8dAc * refactor: rename handler types to drop redundant Service suffix UserService → Users, PostService → Posts, CommentService → Comments, MailService → Mail. Matches micro/blog naming convention. https://claude.ai/code/session_01GkduEhcrqcG45rdfYh8dAc * refactor: consolidate top-level directories, reduce framework bloat Move internal/non-public packages behind internal/ or into their parent packages where they belong: - deploy/ → gateway/mcp/deploy/ (Helm charts belong with the gateway) - profile/ → service/profile/ (preset plugin profiles are a service concern) - scripts/ → internal/scripts/ (install script is not public API) - test/ → internal/test/ (test harness is not public API) - util/ → internal/util/ (internal helpers shouldn't be imported externally) Also fixes CLAUDE.md merge conflict markers and updates project structure documentation. All import paths updated. Build and tests pass. https://claude.ai/code/session_01GkduEhcrqcG45rdfYh8dAc * refactor: redesign model package to match framework conventions Rename model.Database interface to model.Model (consistent with client.Client, server.Server, store.Store). Remove generics in favor of interface{}-based API with reflection. Key changes: - model.Model interface: Register once, CRUD infers table from type - DefaultModel + NewModel() + package-level convenience functions - Schema registered via Register(&User{}), no per-call schema passing - Memory implementation as default (in model package, like store) - memory/sqlite/postgres backends updated for new interface - protoc-gen-micro generates RegisterXModel() instead of generic factory - All docs, blog, and README updated https://claude.ai/code/session_01GkduEhcrqcG45rdfYh8dAc --------- Co-authored-by: Claude <noreply@anthropic.com>
86 行
3.3 KiB
Go
86 行
3.3 KiB
Go
package mdns
|
|
|
|
import "github.com/miekg/dns"
|
|
|
|
// DNSSDService is a service that complies with the DNS-SD (RFC 6762) and MDNS
|
|
// (RFC 6762) specs for local, multicast-DNS-based discovery.
|
|
//
|
|
// DNSSDService implements the Zone interface and wraps an MDNSService instance.
|
|
// To deploy an mDNS service that is compliant with DNS-SD, it's recommended to
|
|
// register only the wrapped instance with the server.
|
|
//
|
|
// Example usage:
|
|
//
|
|
// service := &mdns.DNSSDService{
|
|
// MDNSService: &mdns.MDNSService{
|
|
// Instance: "My Foobar Service",
|
|
// Service: "_foobar._tcp",
|
|
// Port: 8000,
|
|
// }
|
|
// }
|
|
// server, err := mdns.NewServer(&mdns.Config{Zone: service})
|
|
// if err != nil {
|
|
// log.Fatalf("Error creating server: %v", err)
|
|
// }
|
|
// defer server.Shutdown()
|
|
type DNSSDService struct {
|
|
MDNSService *MDNSService
|
|
}
|
|
|
|
// Records returns DNS records in response to a DNS question.
|
|
//
|
|
// This function returns the DNS response of the underlying MDNSService
|
|
// instance. It also returns a PTR record for a request for "
|
|
// _services._dns-sd._udp.<Domain>", as described in section 9 of RFC 6763
|
|
// ("Service Type Enumeration"), to allow browsing of the underlying MDNSService
|
|
// instance.
|
|
func (s *DNSSDService) Records(q dns.Question) []dns.RR {
|
|
var recs []dns.RR
|
|
if q.Name == "_services._dns-sd._udp."+s.MDNSService.Domain+"." {
|
|
recs = s.dnssdMetaQueryRecords(q)
|
|
}
|
|
return append(recs, s.MDNSService.Records(q)...)
|
|
}
|
|
|
|
// dnssdMetaQueryRecords returns the DNS records in response to a "meta-query"
|
|
// issued to browse for DNS-SD services, as per section 9. of RFC6763.
|
|
//
|
|
// A meta-query has a name of the form "_services._dns-sd._udp.<Domain>" where
|
|
// Domain is a fully-qualified domain, such as "local.".
|
|
func (s *DNSSDService) dnssdMetaQueryRecords(q dns.Question) []dns.RR {
|
|
// Intended behavior, as described in the RFC:
|
|
// ...it may be useful for network administrators to find the list of
|
|
// advertised service types on the network, even if those Service Names
|
|
// are just opaque identifiers and not particularly informative in
|
|
// isolation.
|
|
//
|
|
// For this purpose, a special meta-query is defined. A DNS query for PTR
|
|
// records with the name "_services._dns-sd._udp.<Domain>" yields a set of
|
|
// PTR records, where the rdata of each PTR record is the two-abel
|
|
// <Service> name, plus the same domain, e.g., "_http._tcp.<Domain>".
|
|
// Including the domain in the PTR rdata allows for slightly better name
|
|
// compression in Unicast DNS responses, but only the first two labels are
|
|
// relevant for the purposes of service type enumeration. These two-label
|
|
// service types can then be used to construct subsequent Service Instance
|
|
// Enumeration PTR queries, in this <Domain> or others, to discover
|
|
// instances of that service type.
|
|
return []dns.RR{
|
|
&dns.PTR{
|
|
Hdr: dns.RR_Header{
|
|
Name: q.Name,
|
|
Rrtype: dns.TypePTR,
|
|
Class: dns.ClassINET,
|
|
Ttl: defaultTTL,
|
|
},
|
|
Ptr: s.MDNSService.serviceAddr,
|
|
},
|
|
}
|
|
}
|
|
|
|
// Announcement returns DNS records that should be broadcast during the initial
|
|
// availability of the service, as described in section 8.3 of RFC 6762.
|
|
// TODO(reddaly): Add this when Announcement is added to the mdns.Zone interface.
|
|
// func (s *DNSSDService) Announcement() []dns.RR {
|
|
// return s.MDNSService.Announcement()
|
|
//}
|